|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1986 Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * This code is derived from software contributed to Berkeley by ! 6: * Computer Consoles Inc. ! 7: * ! 8: * Redistribution and use in source and binary forms are permitted ! 9: * provided that: (1) source distributions retain this entire copyright ! 10: * notice and comment, and (2) distributions including binaries display ! 11: * the following acknowledgement: ``This product includes software ! 12: * developed by the University of California, Berkeley and its contributors'' ! 13: * in the documentation or other materials provided with the distribution ! 14: * and in all advertising materials mentioning features or use of this ! 15: * software. Neither the name of the University nor the names of its ! 16: * contributors may be used to endorse or promote products derived ! 17: * from this software without specific prior written permission. ! 18: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR ! 19: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED ! 20: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 21: */ ! 22: ! 23: #if defined(SYSLIBC_SCCS) && !defined(lint) ! 24: .asciz "@(#)addf.s 1.3 (Berkeley) 6/1/90" ! 25: #endif /* SYSLIBC_SCCS and not lint */ ! 26: ! 27: #include <tahoemath//fp.h> ! 28: #include "DEFS.h" ! 29: ! 30: XENTRY(addf, R2|R3|R4|R5|R6|R7|R8|R9|R10) ! 31: /* ! 32: * see which operand has a greater exponent ! 33: * The greater one will be fetched into r0,r2,r3. ! 34: * r0- 'pure' fraction, r2 - exponent, r3 - sign). ! 35: * The smaller operand will be fetched into r4,r6,r7. ! 36: */ ! 37: clrl r1 ! 38: andl3 $EXPMASK,4(fp),r0 ! 39: andl3 $EXPMASK,12(fp),r1 ! 40: cmpl r0,r1 ! 41: jgtr first_greater ! 42: ! 43: movl 12(fp),r0 # bigger operand to r0 ! 44: ! 45: movl 4(fp),r4 # smaller operand to r4 ! 46: jmp expo ! 47: ! 48: first_greater: ! 49: movl 4(fp),r0 # bigger operand to r0 ! 50: ! 51: movl 12(fp),r4 # smaller operand to r4 ! 52: ! 53: ! 54: /* ! 55: *compute exponents: ! 56: */ ! 57: expo: ! 58: andl3 $EXPMASK,r0,r2 # r2 will hold the exponent of greater operand. ! 59: jeql is_res1 # check for reserved operand. ! 60: shrl $EXPSHIFT,r2,r2 ! 61: ! 62: ! 63: andl3 $EXPMASK,r4,r6 # r6 will hold the exponent of smaller operand. ! 64: jeql is_res2 # check for reserved operand. ! 65: shrl $EXPSHIFT,r6,r6 ! 66: /* ! 67: *compare the exponents: ! 68: */ ! 69: subl3 r6,r2,r8 ! 70: jeql signs ! 71: cmpl r8,$MAX_EXP_DIF ! 72: jlss signs ! 73: ret # return the bigger number. ! 74: ! 75: /* ! 76: *remember the signs: ! 77: */ ! 78: signs: ! 79: clrl r3 ! 80: bbc $31,r0,sign2 # if negative remember it.(R3=1) ! 81: incl r3 ! 82: sign2: ! 83: clrl r7 ! 84: bbc $31,r4,frac # if negative remember it.(R7=1) ! 85: incl r7 ! 86: /* ! 87: *compute 'pure' fraction: ! 88: */ ! 89: frac: ! 90: # clear the non fraction parts. ! 91: andl2 $(0!(EXPMASK | SIGNBIT)),r0 ! 92: # add the hidden bit. ! 93: orl2 $(0!CLEARHID),r0 ! 94: # clear the non fraction parts. ! 95: andl2 $(0!(EXPMASK | SIGNBIT)),r4 ! 96: # add the hidden bit. ! 97: orl2 $(0!CLEARHID),r4 ! 98: ! 99: /* ! 100: *shift the smaller operand: ! 101: */ ! 102: shar r8,r4,r4 ! 103: eql_exps: ! 104: cmpl r3,r7 ! 105: jeql add ! 106: bbc $0,r3,negr4 ! 107: /* ! 108: *negate r0: ! 109: */ ! 110: clrl r3 ! 111: mnegl r0,r0 ! 112: ! 113: /* ! 114: *add the fractions: ! 115: */ ! 116: add: ! 117: clrl r10 ! 118: addl2 r4,r0 ! 119: jgeq norm ! 120: incl r10 ! 121: /* ! 122: *negate the pair r0,r1: ! 123: */ ! 124: mnegl r0,r0 ! 125: norm: callf $4,sfnorm ! 126: ! 127: /* ! 128: *add the sign bit ! 129: */ ! 130: bbs $0,r10,negative ! 131: bbs $0,r3,negative # the bigger operand was negative. ! 132: ret ! 133: negative: ! 134: orl2 $SIGNBIT,r0 ! 135: ret ! 136: ! 137: ! 138: /* ! 139: *negate r4: ! 140: */ ! 141: negr4: ! 142: mnegl r4,r4 ! 143: jmp add ! 144: ! 145: ! 146: is_res1: ! 147: bbs $31,r0,res_op ! 148: movl r4,r0 # return the smaller operand. ! 149: ret ! 150: ! 151: is_res2: ! 152: bbs $31,r4,res_op ! 153: ret # we allready have the 'result' in r0,r1. ! 154: ! 155: res_op: ! 156: callf $4,sfpresop ! 157: ret
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.