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