|
| single float to double float conversion routine
|
	.text
	.even
	.globl	__extendsfdf2, ___extendsfdf2

__extendsfdf2:
___extendsfdf2:

#ifndef	__M68881__
# ifndef sfp004
|
| written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
| Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
|
| Revision 1.2, kub 01-90 :
| added support for denormalized numbers
|
| Revision 1.1, kub 12-89 :
| Ported over to 68k assembler
|
| Revision 1.0:
| original 8088 code from P.S.Housel

BIAS4	=	0x7F-1
BIAS8	=	0x3FF-1

	lea	sp@(4),a0	| parameter pointer
	moveml	d2-d7,sp@-	| save regs to keep norm_df happy
	movel	a0@,d4		| get number
	clrl	d5		| prepare double mantissa

	movew	a0@,d0		| extract exponent
	movew	d0,d2		| extract sign
	lsrw	#7,d0
	andw	#0xff,d0	| kill sign bit (exponent is 8 bits)
	andl	#0x7fffff,d4	| remove exponent from mantissa

	cmpb	#0xff,d0
	bne	nospec
	tstl	d4
	beq	retinf
| ret nan
	movel	#0x7fffffff,d0
	moveql	#-1,d1
return:	moveml	sp@+,d2-d7
	rts
retinf:	clrl	d1
	movel	#0x7ff00000,d0
	tstw	d2
	bpl	return
	bset	#31,d0
	bra	return

	
nospec:	tstw	d0		| check for zero exponent - no leading "1"
	beq	0f		| for denormalized numbers
	orl	#0x800000,d4	| restore implied leading "1"
	bra	1f
0:	addw	#1,d0		| "normalize" exponent
1:
	addw	#BIAS8-BIAS4-3,d0	| adjust bias, account for shift
	clrw	d1		| dummy rounding info

	jmp	norm_df

# else	sfp004

| single precision floating point stuff for Atari-gcc using the SFP004
| developed with gas
|
| single float to double float conversion routine
|
| M. Ritzert (mjr at dmzrzu71)
|
| 4.10.1990
|
| no NAN checking implemented since the 68881 treats this situation "correct",
| i.e. according to IEEE

| addresses of the 68881 data port. This choice is fastest when much data is
| transferred between the two processors.

comm =	 -6
resp =	-16
zahl =	  0

| waiting loop ...
|
| wait:
| ww:	cmpiw	#0x8900,a1@(resp)
| 	beq	ww
| is coded directly by
|	.long	0x0c688900, 0xfff067f8

	lea	0xfffffa50:w,a0
	movew	#0x4400,a0@(comm)	| load argument to fp0
	cmpiw	#0x8900,a0@(resp)	| check
	movel	a7@(4),a0@		| now push arg
	movew	#0x7400,a0@(comm)	| result to d0/d1
	.long	0x0c688900, 0xfff067f8
	movel	a0@,d0			| pop double float
	movel	a0@,d1
	rts

# endif	sfp004
#else	__M68881__

| mjr:	provided for safety. should be never called.
|
| single precision floating point stuff for Atari-gcc
| developed with gas
|
| single float to double float conversion routine
|
| M. Ritzert (mjr at dfg.dbp.de)
|
| 4.10.1990
| 11.11.1991
|
| no NAN checking implemented since the 68881 treats this situation "correct",
| i.e. according to IEEE

	fmoves	a7@(4),fp0	| load argument to fp0
	fmoved	fp0,a7@-	| read back as double
	moveml	a7@+,d0-d1
	rts

#endif	__M68881__
