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 "@(#)cvtuf.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(cvtuf, R2|R3|R4|R5) 19 # 20 # Some initializations: 21 # 22 clrl r1 23 clrl r2 # r2 - exponent. 24 movl 4(fp),r0 # fetch operand. 25 jeql retzero # return zero. 26 # 27 # Compute exponent: 28 # 29positive: 30 ffs r0,r1 31 incl r1 32 addl2 r1,r2 33 shrl r1,r0,r0 34 jneq positive # look for more set bits. 35 # 36 # we have the exponent in r2. 37 # 38 movl 4(fp),r0 # r0 will hold the resulting f.p. number. 39 # 40 # Shift the fraction part to its proper place: 41 # 42 subl3 r2,$HID_POS,r3 43 jlss shiftr # if less then zero we have to shift right. 44 shll r3,r0,r0 # else we shift left. 45 jmp shifted 46shiftr: 47 mnegl r3,r3 48 shrl r3,r0,r0 49shifted: 50 andl2 $CLEARHID,r0 # clear the hidden bit. 51 shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place. 52 orl2 $EXPSIGN,r2 # set the exponent sign bit(to bias it). 53 orl2 r2,r0 # combine exponent & fraction. 54sign_ok: 55 ret 56 57retzero: 58 clrl r0 59 ret 60 61 62