|
|
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 "@(#)cvtld.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(cvtld, R2|R3|R4|R5) ! 31: # ! 32: #Some initializations: ! 33: # ! 34: clrl r4 # r4 - negative flag. ! 35: clrl r2 # r2 - exponent. ! 36: movl 4(fp),r0 # fetch operand. ! 37: movl r0,r5 # need another copy. ! 38: jeql retzero # return zero. ! 39: jgtr positive ! 40: mnegl r0,r0 ! 41: jvs retmin # return minimum integer. ! 42: incl r4 # remember it was negative. ! 43: movl r0,r5 # remember the negated value. ! 44: # ! 45: #Compute exponent: ! 46: # ! 47: positive: ! 48: ffs r0,r1 ! 49: incl r1 ! 50: addl2 r1,r2 ! 51: shrl r1,r0,r0 ! 52: jneq positive # look for more set bits. ! 53: # ! 54: #we have the exponent in r2. ! 55: # ! 56: movl r5,r0 # r0,r1 will hold the resulting f.p. number. ! 57: clrl r1 ! 58: # ! 59: #Shift the fraction part to its proper place: ! 60: # ! 61: subl3 r2,$HID_POS,r3 ! 62: jlss shiftr # if less then zero we have to shift right. ! 63: shll r3,r0,r0 # else we shift left. ! 64: jmp shifted ! 65: shiftr: ! 66: mnegl r3,r3 ! 67: shrq r3,r0,r0 ! 68: shifted: ! 69: andl2 $CLEARHID,r0 # clear the hidden bit. ! 70: shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place. ! 71: orl2 $EXPSIGN,r2 # set the exponent sign bit(to bias it). ! 72: orl2 r2,r0 # combine exponent & fraction. ! 73: bbc $0,r4,sign_ok # do we have to set the sign bit? ! 74: orl2 $SIGNBIT,r0 # yes... ! 75: sign_ok: ! 76: ret ! 77: ! 78: retzero: ! 79: clrl r0 ! 80: clrl r1 ! 81: ret ! 82: ! 83: retmin: ! 84: movl $0xd0000000,r0 ! 85: clrl r1 ! 86: ret ! 87: ! 88: ! 89:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.