Commit | Line | Data |
---|---|---|
a6730a00 | 1 | /* Ksfnorm.s 1.4 90/12/04 */ |
5245a337 | 2 | |
a6730a00 KB |
3 | #include "../math/fp.h" |
4 | #include "../math/Kfp.h" | |
9d1834ba | 5 | #include "../tahoe/SYS.h" |
5245a337 | 6 | |
2b252132 SL |
7 | /* |
8 | * Ksfnorm(hfs) | |
9 | */ | |
5245a337 | 10 | .text |
2b252132 | 11 | ENTRY(Ksfnorm, R6|R5|R4|R3|R2) |
5245a337 SL |
12 | clrl r1 |
13 | movl r0,r4 /* copy to temporary. */ | |
14 | jeql retzero | |
15 | clrl r3 /* r3 - pos of m.s.b */ | |
16 | inr00: ffs r4,r6 | |
17 | incl r6 | |
18 | addl2 r6,r3 | |
19 | shrl r6,r4,r4 | |
20 | jneq inr00 | |
21 | ||
22 | cmpshift: | |
23 | /* compute the shift (r4). */ | |
24 | subl3 r3,$HID_POS,r4 | |
25 | jlss shiftr /* if less then zero we shift right. */ | |
26 | shll r4,r0,r0 /* else we shift left. */ | |
27 | subl2 r4,r2 /* uodate exponent. */ | |
28 | jleq underflow /* if less then 0 (biased) it is underflow. */ | |
29 | jmp combine /* go to combine exponent and fraction. */ | |
30 | shiftr: | |
31 | mnegl r4,r4 | |
32 | shrl r4,r0,r0 /* shift right. */ | |
33 | addl2 r4,r2 /* update exponent */ | |
34 | cmpl r2,$256 | |
35 | jgeq overflow /* check for overflow. */ | |
36 | combine: | |
37 | andl2 $CLEARHID,r0 /* clear the hidden bit. */ | |
38 | shal $EXPSHIFT,r2,r2 /* shift the exponent to its proper place. */ | |
39 | orl2 r2,r0 | |
40 | ret | |
41 | ||
42 | underflow: | |
43 | orl2 $HFS_UNDF,*4(fp) | |
44 | ret | |
45 | ||
46 | overflow: | |
47 | orl2 $HFS_OVF,*4(fp) | |
48 | ret | |
49 | retzero: | |
50 | clrl r0 | |
51 | ret |