.globl	fpsim, fpsr, m.ext, m.lngi
.globl	pow, _pow
.globl	log, exp

_pow:
	mov	r5,-(sp)
	mov	sp,r5
jsr	pc, fpsim
	movf	4(r5),fr0
	movf	12.(r5),fr1
	jsr	pc,pow
	mov	(sp)+,r5
	rts	pc

pow:

/ 0^0~ is 0

jsr	pc, fpsim
	tstf	fr0
	cfcc
	bne	1f
jsr	pc, fpsim
	tstf	fr1
	cfcc
	beq	bad
	rts	pc
1:

/ -^i is +^i fixed sign

	bpl	1f
jsr	pc, fpsim
	movf	fr1,-(sp)
	modf	$one,fr1
	cfcc
	bne	bad1
jsr	pc, fpsim
	movf	(sp)+,fr1
	absf	fr0
	jsr	pc,1f
	bes	bad
jsr	pc, fpsim
	movf	fr1,-(sp)
	modf	$half,fr1
	cfcc
	beq	2f
jsr	pc, fpsim
	negf	fr0
2:
jsr	pc, fpsim
	movf	(sp)+,fr1
	rts	pc
1:
	jsr	pc,log
	bes	1f
jsr	pc, fpsim
	mulf	 fr1,fr0
	jsr	pc,exp
1:
	rts	pc

bad1:
jsr	pc, fpsim
	movf	(sp)+,fr1
bad:
	sec
	rts	pc

one = 40200
half = 40000
