2 /*---------------------------------------------------------------------------+
5 | Add two valid (TAG_Valid) FPU_REG numbers, of the same sign, and put the |
6 | result in a destination FPU_REG. |
8 | Copyright (C) 1992,1993,1995,1997 |
9 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
10 | E-mail billm@suburbia.net |
13 | int FPU_u_add(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ, |
15 | Return value is the tag of the answer, or-ed with FPU_Exception if |
16 | one was raised, or -1 on internal error. |
18 +---------------------------------------------------------------------------*/
21 | Kernel addition routine FPU_u_add(reg *arg1, reg *arg2, reg *answ).
22 | Takes two valid reg f.p. numbers (TAG_Valid), which are
23 | treated as unsigned numbers,
24 | and returns their sum as a TAG_Valid or TAG_Special f.p. number.
25 | The returned number is normalized.
26 | Basic checks are performed if PARANOID is defined.
29 #include "exception.h"
31 #include "control_w.h"
41 movl PARAM1,%esi /* source 1 */
42 movl PARAM2,%edi /* source 2 */
46 subl PARAM7,%ecx /* exp1 - exp2 */
59 /* num1 has larger or equal exponent */
64 movl PARAM3,%edi /* destination */
65 movw %dx,EXP(%edi) /* Copy exponent to destination */
67 xorl %edx,%edx /* clear the extension */
70 testl $0x80000000,%eax
73 testl $0x80000000,SIGH(%esi)
77 /* The number to be shifted is in %eax:%ebx:%edx */
78 cmpw $32,%cx /* shrd only works for 0..31 bits */
81 /* less than 32 bits */
97 jz L_more_31_no_low /* none of the lowest bits is set */
99 orl $1,%edx /* record the fact in the extension */
124 movl $1,%edx /* The shifted nr always at least one '1' */
131 /* Now do the addition */
134 jnc L_round_the_result
136 /* Overflow, adjust the result */
148 jmp fpu_reg_round /* Round the result */
153 /* If we ever get here then we have problems! */
155 pushl EX_INTERNAL|0x201
167 #endif /* PARANOID */