*** tempfns.s
*	Stopgap functions for floating point
*	for Alcyon C
*
* 	The functions in this file call the corresponding libm function
*	because I don't know EXACTLY how they work.  (Does dptol round
*	toward zero? Yes, it does, but that's the kind of thing I can't
*	be sure I have translated correctly to the hardware.)
*
*	Some functions here are easy to do for both HW and SW:
*	[u]ito[d/s]p is just lto[s/d]p after converting the int
*	to an appropriate long; abs is easier to do this way
*	than going to the chip; l[div/mul/rem]u are here because
*	they are in libm, and they jump to _Xl...u because that's
*	easier than reproducing those things here.
*
*	Copyright Atari Corp. 1987,1988
*
*	AKPratt		7/20/88
*	I'm a little sorry to put my name on this, but it can't be helped.
***

.globl	_dpint, _dptoi, _dptol, _dptoui, _dptoul, _frexp, _itodp, _itosp
.globl	_powl, _spabs, _fabs, _spint, _sptoi, _sptoui, _sptol, _sptoul, _uitodp
.globl	_ultodp, _uitosp, _ultosp
.globl	_ldivu, _lremu, _lmulu

.extern	_Xdpint, _Xdptoi, _Xdptol, _Xdptoui, _Xdptoul, _Xfrexp, _Xitodp
.extern	_Xitosp, _Xpowl, _Xspint, _Xsptoi, _Xsptol, _Xsptoui
.extern	_Xsptoul, _Xuitodp, _Xultodp, _Xuitosp, _Xultosp
.extern _Xldivu, _Xlremu, _Xlmulu

.extern	_ltodp, _ltosp

_dpint:		bra	_Xdpint
_dptoi:		bra	_Xdptoi
_dptoui:	bra	_Xdptoui
_dptoul:	bra	_Xdptoul
_dptol:		bra	_Xdptol
_frexp:		bra	_Xfrexp
_powl:		bra	_Xpowl
_spint:		bra	_Xspint
_sptoi:		bra	_Xsptoi
_sptol:		bra	_Xsptol
_sptoui:	bra	_Xsptoui
_sptoul:	bra	_Xsptoul
_ultodp:	bra	_Xultodp
_ultosp:	bra	_Xultosp

; int to dp: turn the int into a long and call ltodp.

_itodp:
	move.w	4(sp),d0
	ext.l	d0
	move.l	d0,-(sp)
	bsr	_ltodp
	addq	#4,sp
	rts

; int to sp: turn the int into a long and call ltosp.

_itosp:
	move.w	4(sp),d0
	ext.l	d0
	move.l	d0,-(sp)
	bsr	_ltosp
	addq	#4,sp
	rts

; unsigned int to dp: pop PC, push word of 0, push PC, bra to ltodp.

_uitodp:
	move.l	(sp)+,d0
	move.w	#$0,-(sp)
	move.l	d0,-(sp)
	bra	_ltodp

; unsigned int to sp: pop PC, push word of 0, push PC, bra to ltosp.

_uitosp:
	move.l	(sp)+,d0
	move.w	#$0,-(sp)
	move.l	d0,-(sp)
	bra	_ltosp

; abs: make the argument positive
_fabs:	move.l	8(sp),d1
_spabs:	move.l	4(sp),d0
	bclr.l	#31,d0
	rts

_ldivu: bra	_Xldivu
_lmulu:	bra	_Xlmulu
_lremu:	bra	_Xlremu
