1 /* SPDX-License-Identifier: GPL-2.0 */
3 /*---------------------------------------------------------------------------+
6 | Add two valid (TAG_Valid) FPU_REG numbers, of the same sign, and put the |
7 | result in a destination FPU_REG. |
9 | Copyright (C) 1992,1993,1995,1997 |
10 | W. Metzenthen, 22 Parker St, Ormond, Vic 3163, Australia |
11 | E-mail billm@suburbia.net |
14 | int FPU_u_add(FPU_REG *arg1, FPU_REG *arg2, FPU_REG *answ, |
16 | Return value is the tag of the answer, or-ed with FPU_Exception if |
17 | one was raised, or -1 on internal error. |
19 +---------------------------------------------------------------------------*/
22 | Kernel addition routine FPU_u_add(reg *arg1, reg *arg2, reg *answ).
23 | Takes two valid reg f.p. numbers (TAG_Valid), which are
24 | treated as unsigned numbers,
25 | and returns their sum as a TAG_Valid or TAG_Special f.p. number.
26 | The returned number is normalized.
27 | Basic checks are performed if PARANOID is defined.
30 #include "exception.h"
32 #include "control_w.h"
42 movl PARAM1,%esi /* source 1 */
43 movl PARAM2,%edi /* source 2 */
47 subl PARAM7,%ecx /* exp1 - exp2 */
60 /* num1 has larger or equal exponent */
65 movl PARAM3,%edi /* destination */
66 movw %dx,EXP(%edi) /* Copy exponent to destination */
68 xorl %edx,%edx /* clear the extension */
71 testl $0x80000000,%eax
74 testl $0x80000000,SIGH(%esi)
78 /* The number to be shifted is in %eax:%ebx:%edx */
79 cmpw $32,%cx /* shrd only works for 0..31 bits */
82 /* less than 32 bits */
98 jz L_more_31_no_low /* none of the lowest bits is set */
100 orl $1,%edx /* record the fact in the extension */
125 movl $1,%edx /* The shifted nr always at least one '1' */
132 /* Now do the addition */
135 jnc L_round_the_result
137 /* Overflow, adjust the result */
149 jmp fpu_reg_round /* Round the result */
154 /* If we ever get here then we have problems! */
156 pushl EX_INTERNAL|0x201
168 #endif /* PARANOID */