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 the above copyright notice and this paragraph are 10 * duplicated in all such forms and that any documentation, 11 * advertising materials, and other materials related to such 12 * distribution and use acknowledge that the software was developed 13 * by the University of California, Berkeley. The name of the 14 * University may not be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 19 */ 20 21#if defined(SYSLIBC_SCCS) && !defined(lint) 22 .asciz "@(#)cvtfl.s 1.2 (Berkeley) 02/17/89" 23#endif /* SYSLIBC_SCCS and not lint */ 24 25#include <tahoemath/fp.h> 26#include "DEFS.h" 27 28XENTRY(cvtfu, R2|R3|R4|R5) 29 jbr 1f 30 31XENTRY(cvtfl, R2|R3|R4|R5) 32 # 33 #Some initializations: 34 # 351: 36 movl 4(fp),r0 # fetch operand. 37 clrl r3 # r3 - negative flag. 38 # 39 #get exponent 40 # 41 andl3 $EXPMASK,r0,r2 # r2 will hold the exponent. 42 jeql is_reserved # check for reserved operand. 43 cmpl $ONE_EXP,r2 # if exponent is less then 1,return zero. 44 jgtr retzero 45 andl2 $0!EXPSIGN,r2 # turn off biased exponent sign 46 shrl $EXPSHIFT,r2,r2 47 # 48 #get fraction 49 # 50 bbc $31,r0,positive # if negative remember it. 51 incl r3 52positive: 53 # clear the non fraction parts. 54 andl2 $(0!(EXPMASK | SIGNBIT)),r0 55 # add the hidden bit. 56 orl2 $(0!CLEARHID),r0 57 subl2 $24,r2 # compute the shift. 58 jgtr shift_left 59 mnegl r2,r2 60 shrl r2,r0,r0 # shift right. 61 jmp shifted 62shift_left: 63 cmpl r2,$7 64 jgtr overflow 65go_on: shll r2,r0,r0 # shift right. 66shifted: 67 bbc $0,r3,done # check for negative 68 mnegl r0,r0 69done: 70 ret 71 72retzero: 73 clrl r0 74 ret 75overflow: 76 callf $4,sfpover 77 jmp go_on 78 79is_reserved: 80 bbc $31,r0,retzero 81 82 callf $4,sfpresop 83 ret 84