1 .file "reg_u_add.S"
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #include "exception.h"
28 #include "fpu_asm.h"
29 #include "control_w.h"
30
31 .text
32 ENTRY(reg_u_add)
33 pushl %ebp
34 movl %esp,%ebp
35 pushl %esi
36 pushl %edi
37 pushl %ebx
38
39 movl PARAM1,%esi
40 movl PARAM2,%edi
41
42 #ifdef DENORM_OPERAND
43 cmpl EXP_UNDER,EXP(%esi)
44 jg xOp1_not_denorm
45
46 call SYMBOL_NAME(denormal_operand)
47 orl %eax,%eax
48 jnz fpu_Arith_exit
49
50 xOp1_not_denorm:
51 cmpl EXP_UNDER,EXP(%edi)
52 jg xOp2_not_denorm
53
54 call SYMBOL_NAME(denormal_operand)
55 orl %eax,%eax
56 jnz fpu_Arith_exit
57
58 xOp2_not_denorm:
59 #endif DENORM_OPERAND
60
61 movl EXP(%esi),%ecx
62 subl EXP(%edi),%ecx
63 jge L_arg1_larger
64
65
66 movl SIGL(%esi),%ebx
67 movl SIGH(%esi),%eax
68
69 movl %edi,%esi
70 negw %cx
71 jmp L_accum_loaded
72
73 L_arg1_larger:
74
75 movl SIGL(%edi),%ebx
76 movl SIGH(%edi),%eax
77
78 L_accum_loaded:
79 movl PARAM3,%edi
80
81
82
83
84 movl EXP(%esi),%edx
85 movl %edx,EXP(%edi)
86
87 xorl %edx,%edx
88
89 #ifdef PARANOID
90 testl $0x80000000,%eax
91 je L_bugged
92
93 testl $0x80000000,SIGH(%esi)
94 je L_bugged
95 #endif PARANOID
96
97
98 cmpw $32,%cx
99 jnc L_more_than_31
100
101
102 shrd %cl,%ebx,%edx
103 shrd %cl,%eax,%ebx
104 shr %cl,%eax
105 jmp L_shift_done
106
107 L_more_than_31:
108 cmpw $64,%cx
109 jnc L_more_than_63
110
111 subb $32,%cl
112 jz L_exactly_32
113
114 shrd %cl,%eax,%edx
115 shr %cl,%eax
116 orl %ebx,%ebx
117 jz L_more_31_no_low
118
119 orl $1,%edx
120
121 L_more_31_no_low:
122 movl %eax,%ebx
123 xorl %eax,%eax
124 jmp L_shift_done
125
126 L_exactly_32:
127 movl %ebx,%edx
128 movl %eax,%ebx
129 xorl %eax,%eax
130 jmp L_shift_done
131
132 L_more_than_63:
133 cmpw $65,%cx
134 jnc L_more_than_64
135
136 movl %eax,%edx
137 orl %ebx,%ebx
138 jz L_more_63_no_low
139
140 orl $1,%edx
141 jmp L_more_63_no_low
142
143 L_more_than_64:
144 movl $1,%edx
145
146 L_more_63_no_low:
147 xorl %ebx,%ebx
148 xorl %eax,%eax
149
150 L_shift_done:
151
152 addl SIGL(%esi),%ebx
153 adcl SIGH(%esi),%eax
154 jnc L_round_the_result
155
156
157 rcrl $1,%eax
158 rcrl $1,%ebx
159 rcrl $1,%edx
160 jnc L_no_bit_lost
161
162 orl $1,%edx
163
164 L_no_bit_lost:
165 incl EXP(%edi)
166
167 L_round_the_result:
168 jmp fpu_reg_round
169
170
171
172 #ifdef PARANOID
173
174 L_bugged:
175 pushl EX_INTERNAL|0x201
176 call EXCEPTION
177 pop %ebx
178 jmp L_exit
179 #endif PARANOID
180
181
182 L_exit:
183 popl %ebx
184 popl %edi
185 popl %esi
186 leave
187 ret