|
|
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 "@(#)cvtuf.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(cvtuf, R2|R3|R4|R5)
31: #
32: # Some initializations:
33: #
34: clrl r1
35: clrl r2 # r2 - exponent.
36: movl 4(fp),r0 # fetch operand.
37: jeql retzero # return zero.
38: #
39: # Compute exponent:
40: #
41: positive:
42: ffs r0,r1
43: incl r1
44: addl2 r1,r2
45: shrl r1,r0,r0
46: jneq positive # look for more set bits.
47: #
48: # we have the exponent in r2.
49: #
50: movl 4(fp),r0 # r0 will hold the resulting f.p. number.
51: #
52: # Shift the fraction part to its proper place:
53: #
54: subl3 r2,$HID_POS,r3
55: jlss shiftr # if less then zero we have to shift right.
56: shll r3,r0,r0 # else we shift left.
57: jmp shifted
58: shiftr:
59: mnegl r3,r3
60: shrl r3,r0,r0
61: shifted:
62: andl2 $CLEARHID,r0 # clear the hidden bit.
63: shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place.
64: orl2 $EXPSIGN,r2 # set the exponent sign bit(to bias it).
65: orl2 r2,r0 # combine exponent & fraction.
66: sign_ok:
67: ret
68:
69: retzero:
70: clrl r0
71: ret
72:
73:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.