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