1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 #include "fpu_emu.h"
18
19
20 .text
21 ENTRY(normalize)
22 pushl %ebp
23 movl %esp,%ebp
24 pushl %ebx
25
26 movl PARAM1,%ebx
27
28 #ifdef PARANOID
29 cmpb TW_Valid,TAG(%ebx)
30 je L_ok
31
32 pushl $0x220
33 call SYMBOL_NAME(exception)
34 addl $4,%esp
35
36 L_ok:
37 #endif PARANOID
38
39 movl SIGH(%ebx),%edx
40 movl SIGL(%ebx),%eax
41
42 orl %edx,%edx
43 js L_done
44 jnz L_shift_1
45
46 orl %eax,%eax
47 jz L_zero
48
49 movl %eax,%edx
50 xorl %eax,%eax
51 subl $32,EXP(%ebx)
52
53
54 L_shift_1:
55 bsrl %edx,%ecx
56 subl $31,%ecx
57 negl %ecx
58 shld %cl,%eax,%edx
59 shl %cl,%eax
60 subl %ecx,EXP(%ebx)
61
62 movl %edx,SIGH(%ebx)
63 movl %eax,SIGL(%ebx)
64
65 L_done:
66 cmpl EXP_OVER,EXP(%ebx)
67 jge L_overflow
68
69 cmpl EXP_UNDER,EXP(%ebx)
70 jle L_underflow
71
72 L_exit:
73 popl %ebx
74 leave
75 ret
76
77
78 L_zero:
79 movl EXP_UNDER,EXP(%ebx)
80 movb TW_Zero,TAG(%ebx)
81 jmp L_exit
82
83 L_underflow:
84 push %ebx
85 call SYMBOL_NAME(arith_underflow)
86 pop %ebx
87 jmp L_exit
88
89 L_overflow:
90 push %ebx
91 call SYMBOL_NAME(arith_overflow)
92 pop %ebx
93 jmp L_exit
94
95
96
97
98 ENTRY(normalize_nuo)
99 pushl %ebp
100 movl %esp,%ebp
101 pushl %ebx
102
103 movl PARAM1,%ebx
104
105 #ifdef PARANOID
106 cmpb TW_Valid,TAG(%ebx)
107 je L_ok_nuo
108
109 pushl $0x221
110 call SYMBOL_NAME(exception)
111 addl $4,%esp
112
113 L_ok_nuo:
114 #endif PARANOID
115
116 movl SIGH(%ebx),%edx
117 movl SIGL(%ebx),%eax
118
119 orl %edx,%edx
120 js L_exit
121 jnz L_nuo_shift_1
122
123 orl %eax,%eax
124 jz L_zero
125
126 movl %eax,%edx
127 xorl %eax,%eax
128 subl $32,EXP(%ebx)
129
130
131 L_nuo_shift_1:
132 bsrl %edx,%ecx
133 subl $31,%ecx
134 negl %ecx
135 shld %cl,%eax,%edx
136 shl %cl,%eax
137 subl %ecx,EXP(%ebx)
138
139 movl %edx,SIGH(%ebx)
140 movl %eax,SIGL(%ebx)
141 jmp L_exit
142
143