use base versions of all the tool names when constructing the kernel tool names.
[AROS.git] / arch / m68k-all / libgcc1 / _truncdfsf2.s
blob7e2e82c2dbfa1b4fca613cd21f76147e399b5be3
1 | double float to single float conversion routine
3 | written by Kai-Uwe Bloem (I5110401@dbstu1.bitnet).
4 | Based on a 80x86 floating point packet from comp.os.minix, written by P.Housel
7 | Revision 1.2, kub 01-90 :
8 | added support for denormalized numbers
10 | Revision 1.1, kub 12-89 :
11 | Ported over to 68k assembler
13 | Revision 1.0:
14 | original 8088 code from P.S.Housel
16 BIAS4 = 0x7F-1
17 BIAS8 = 0x3FF-1
19 .text
20 .even
21 .globl __truncdfsf2
23 __truncdfsf2:
24 lea %sp@(4),%a0 | parameter pointer
25 moveml %d2-%d5,%sp@- | save regs
26 moveml %a0@,%d4-%d5 | get number
28 movew %a0@,%d0 | extract exponent
29 movew %d0,%d2 | extract sign
30 lsrw #4,%d0
31 andw #0x7ff,%d0 | kill sign bit
33 andl #0x0fffff,%d4 | remove exponent from mantissa
34 tstw %d0 | check for zero exponent - no leading "1"
35 beq L_0 | for denormalized numbers
36 orl #0x100000,%d4 | restore implied leading "1"
37 bra L_1
38 L_0: addw #1,%d0 | "normalize" exponent
39 L_1:
40 addw #BIAS4-BIAS8,%d0 | adjust bias
42 addl %d5,%d5 | shift up to realign mantissa for floats
43 addxl %d4,%d4
44 addl %d5,%d5
45 addxl %d4,%d4
46 addl %d5,%d5
47 addxl %d4,%d4
49 movel %d5,%d1 | set rounding bits
50 roll #8,%d1
51 andl #0x00ffffff,%d5 | check to see if sticky bit should be set
52 beq L_2
53 orb #1,%d1 | set sticky bit
54 L_2:
55 jmp norm_sf | (leave regs on stack for norm_sf)