1 | single float to long conversion routine
11 lea
%sp@
(4),%a0 | pointer to parameters
12 moveml
%d2
/%d4
/%d5
,%sp@
- | save registers
13 movel
%a0@
,%d4 | get the number
14 movew
%a0@
,%d0 | extract exp
15 movew
%d0
,%d2 | extract sign
17 andw
#0xff,%d0 | kill sign bit
19 andl
#0x7fffff,%d4 | remove exponent from mantissa
20 orl
#0x800000,%d4 | restore implied leading "1"
22 cmpw #BIAS4,%d0 | check exponent
23 blt zero | strictly factional
, no integer part ?
24 cmpw #BIAS4+32,%d0 | is it too big to fit in a 32-bit integer ?
27 subw
#BIAS4+24,%d0 | adjust exponent
31 cmpw #-8,%d0 | replace far shifts by swap
33 movew
%d4
,%d5 | shift fast
, 16 bits
37 addw
#16,%d0 | account for swap
41 L_1
: lsrl
#1,%d4 | shift down to align radix point;
42 addw
#1,%d0 | extra bits fall off the end (no rounding)
43 blt L_1 | shifted all the way down yet ?
46 L_2
: addl
%d5
,%d5 | shift up to align radix point
51 L_3
: movel
%d4
,%d0 | put integer into result register
52 cmpl #0x80000000,%d0 | -2147483648 is a nasty evil special case
54 tstw
%d2 | this had better
be -2^
31 and not 2^
31
57 L_6
: tstl
%d0 | sign bit set ?
(i.e. too big
)
60 tstw
%d2 | is it negative ?
64 moveml
%sp@
+,%d2
/%d4
/%d5
68 clrl
%d0 | make the whole thing zero
72 movel
#0x7fffffff,%d0 | ugh. Should cause a trap here.