.globl	fpsim, fpsr, m.ext, m.lngi
.globl	_floor, _ceil
.globl	floor, ceil
one = 40200

_floor:
	mov	r5,-(sp)
	mov	sp,r5
jsr	pc, fpsim
	movf	4(r5),fr0
	jsr	pc,floor
	br	1f

_ceil:
	mov	r5,-(sp)
	mov	sp,r5
jsr	pc, fpsim
	movf	4(r5),fr0
	jsr	pc,ceil
1:
	mov	(sp)+,r5
	rts	pc

floor:
jsr	pc, fpsim
	tstf	fr0
	cfcc
	bge	1f
jsr	pc, fpsim
	modf	$one,fr0
	cfcc
	beq	2f
jsr	pc, fpsim
	subf	$one,fr1
	br	2f
1:
jsr	pc, fpsim
	modf	$one,fr0
2:
jsr	pc, fpsim
	movf	fr1,fr0
	rts	pc

ceil:
jsr	pc, fpsim
	negf	fr0
	jsr	pc,floor
jsr	pc, fpsim
	negf	fr0
	rts	pc
