1 ! bcc 386 floating point routines (version 2) -- Fmul, Fmuld, Fmulf
6 #define FRAME_SIZE (3 * GENREG_SIZE + PC_SIZE)
19 mov eax,FRAME_SIZE+D_LOW[esp]
20 mov edx,FRAME_SIZE+D_HIGH[esp]
21 mov ebx,FRAME_SIZE+D_SIZE+D_LOW[esp]
22 mov ecx,FRAME_SIZE+D_SIZE+D_HIGH[esp]
24 mov FRAME_SIZE+D_SIZE+D_LOW[esp],eax
25 mov FRAME_SIZE+D_SIZE+D_HIGH[esp],edx
37 mov eax,FRAME_SIZE+D_LOW[esp]
38 mov edx,FRAME_SIZE+D_HIGH[esp]
42 mov FRAME_SIZE+D_LOW[esp],eax
43 mov FRAME_SIZE+D_HIGH[esp],edx
58 mov eax,FRAME_SIZE+D_LOW[esp] ! xl
59 mov edx,FRAME_SIZE+D_HIGH[esp] ! xu
61 mov FRAME_SIZE+D_LOW[esp],eax
62 mov FRAME_SIZE+D_HIGH[esp],edx
70 mov edx,#1 << D_EXP_SHIFT ! change exponent from 0 to 1
71 jmp x_unpacked ! XXX - check for denormal?
75 mov ecx,#1 << D_EXP_SHIFT
82 and ebp,#D_SIGN_MASK ! sign of result is difference of signs
84 mov esi,edx ! free edx for multiplications
85 and esi,#D_FRAC_MASK ! discard sign and exponent
86 and edx,#D_EXP_MASK ! exponent(x)
88 or esi,#D_NORM_MASK ! normalize
91 mov edi,ecx ! this mainly for consistent naming
93 and ecx,#D_EXP_MASK ! exponent(y)
98 add ecx,edx ! add exponents
100 ! exponent is in ecx, sign in ebp, operands in esi:eax and edi:ebx, edx is free
101 ! product to go in esi:eax:ebp:ebx
102 ! terminology: x * y = (xu,xl) * (yu,yl)
103 ! = (xu * yu,0,0) + (0,xu * yl + xl * yu,0) + (0,0,xl * yl)
109 mov ebp,edx ! (xl * yl).u in ebp
110 xchg ebx,eax ! (xl * yl).l in ebx (final), yl in eax
112 push eax ! (xu * yl).l on stack
113 push edx ! (xu * yl).u on stack
116 mov esi,edx ! (xu * yu).u in esi (final except carries)
117 xchg ecx,eax ! (xu * yu).l in ecx, xl in eax
120 add ebp,eax ! (xl * yl).u + (xl * yu).l
121 pop eax ! (xu * yl).u
122 adc eax,edx ! (xu * yl).u + (xl * yu).u
124 pop edx ! (xu * yl).l
125 add ebp,edx ! ((xl * yl).u + (xl * yu).l) + (xu * yl).l
126 adc eax,ecx ! ((xu * yl).u + (xl * yu).u) + (xu * yu).l
130 sub edi,#(D_EXP_BIAS+1-(D_EXP_BIT+2)) << D_EXP_SHIFT ! adjust
131 ! cmp edi,#(D_EXP_INFINITE-1+(D_EXP_BIT+2)) << D_EXP_SHIFT
132 ! jae outofbounds ! 0 will be caught as underflow by normalize2
133 cmp edi,#(2*D_EXP_INFINITE-(D_EXP_BIAS+1)+(D_EXP_BIT+2)) << D_EXP_SHIFT
139 mov edx,ebp ! put sign in usual reg
141 mov eax,ecx ! XXX - wrong reg
146 mov edx,ebp ! put sign in usual reg