1/* 2 * Copyright (c) 1986, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Computer Consoles Inc. 7 * 8 * %sccs.include.redist.c% 9 */ 10 11#if defined(SYSLIBC_SCCS) && !defined(lint) 12 .asciz "@(#)addf.s 8.1 (Berkeley) 06/04/93" 13#endif /* SYSLIBC_SCCS and not lint */ 14 15#include <tahoemath/fp.h> 16#include "DEFS.h" 17 18XENTRY(addf, R2|R3|R4|R5|R6|R7|R8|R9|R10) 19/* 20 * see which operand has a greater exponent 21 * The greater one will be fetched into r0,r2,r3. 22 * r0- 'pure' fraction, r2 - exponent, r3 - sign). 23 * The smaller operand will be fetched into r4,r6,r7. 24 */ 25 clrl r1 26 andl3 $EXPMASK,4(fp),r0 27 andl3 $EXPMASK,12(fp),r1 28 cmpl r0,r1 29 jgtr first_greater 30 31 movl 12(fp),r0 # bigger operand to r0 32 33 movl 4(fp),r4 # smaller operand to r4 34 jmp expo 35 36first_greater: 37 movl 4(fp),r0 # bigger operand to r0 38 39 movl 12(fp),r4 # smaller operand to r4 40 41 42/* 43 *compute exponents: 44 */ 45expo: 46 andl3 $EXPMASK,r0,r2 # r2 will hold the exponent of greater operand. 47 jeql is_res1 # check for reserved operand. 48 shrl $EXPSHIFT,r2,r2 49 50 51 andl3 $EXPMASK,r4,r6 # r6 will hold the exponent of smaller operand. 52 jeql is_res2 # check for reserved operand. 53 shrl $EXPSHIFT,r6,r6 54/* 55 *compare the exponents: 56 */ 57 subl3 r6,r2,r8 58 jeql signs 59 cmpl r8,$MAX_EXP_DIF 60 jlss signs 61 ret # return the bigger number. 62 63/* 64 *remember the signs: 65 */ 66signs: 67 clrl r3 68 bbc $31,r0,sign2 # if negative remember it.(R3=1) 69 incl r3 70sign2: 71 clrl r7 72 bbc $31,r4,frac # if negative remember it.(R7=1) 73 incl r7 74/* 75 *compute 'pure' fraction: 76 */ 77frac: 78 # clear the non fraction parts. 79 andl2 $(0!(EXPMASK | SIGNBIT)),r0 80 # add the hidden bit. 81 orl2 $(0!CLEARHID),r0 82 # clear the non fraction parts. 83 andl2 $(0!(EXPMASK | SIGNBIT)),r4 84 # add the hidden bit. 85 orl2 $(0!CLEARHID),r4 86 87/* 88 *shift the smaller operand: 89 */ 90 shar r8,r4,r4 91eql_exps: 92 cmpl r3,r7 93 jeql add 94 bbc $0,r3,negr4 95/* 96 *negate r0: 97 */ 98 clrl r3 99 mnegl r0,r0 100 101/* 102 *add the fractions: 103 */ 104add: 105 clrl r10 106 addl2 r4,r0 107 jgeq norm 108 incl r10 109/* 110 *negate the pair r0,r1: 111 */ 112 mnegl r0,r0 113norm: callf $4,sfnorm 114 115/* 116 *add the sign bit 117 */ 118 bbs $0,r10,negative 119 bbs $0,r3,negative # the bigger operand was negative. 120 ret 121negative: 122 orl2 $SIGNBIT,r0 123 ret 124 125 126/* 127 *negate r4: 128 */ 129negr4: 130 mnegl r4,r4 131 jmp add 132 133 134is_res1: 135 bbs $31,r0,res_op 136 movl r4,r0 # return the smaller operand. 137 ret 138 139is_res2: 140 bbs $31,r4,res_op 141 ret # we allready have the 'result' in r0,r1. 142 143res_op: 144 callf $4,sfpresop 145 ret 146