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