1/*- 2 * Copyright (c) 1985 The 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 * %sccs.include.redist.c% 9 * 10 * @(#)Kcvtfl.s 7.1 (Berkeley) 12/06/90 11 */ 12 13#include "../math/fp.h" 14#include "../tahoe/SYS.h" 15 16 .text 17ENTRY(Kcvtfl, R5|R4|R3|R2) 18 clrl r1 19 clrl r4 # r4 - negative flag. 20 clrl r2 # r2 - exponent. 21 movl 4(fp),r0 # fetch operand. 22 movl r0,r5 # need another copy. 23 jeql retzero # return zero. 24 jgtr positive 25 mnegl r0,r0 26 jvs retmin # return minimum integer. 27 incl r4 # remember it was negative. 28 movl r0,r5 # remember the negated value. 29 # 30 #Compute exponent: 31 # 32positive: 33 ffs r0,r1 34 incl r1 35 addl2 r1,r2 36 shrl r1,r0,r0 37 jneq positive # look for more set bits. 38 # 39 #we have the exponent in r2. 40 # 41 movl r5,r0 # r0 will hold the resulting f.p. number. 42 # 43 #Shift the fraction part to its proper place: 44 # 45 subl3 r2,$HID_POS,r3 46 jlss shiftr # if less then zero we have to shift right. 47 shll r3,r0,r0 # else we shift left. 48 jmp shifted 49shiftr: 50 mnegl r3,r3 51 shrl r3,r0,r0 52shifted: 53 andl2 $CLEARHID,r0 # clear the hidden bit. 54 shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place. 55 orl2 $EXPSIGN,r2 # set the exponent sign bit(to bias it). 56 orl2 r2,r0 # combine exponent & fraction. 57 bbc $0,r4,sign_ok # do we have to set the sign bit? 58 orl2 $SIGNBIT,r0 # yes... 59sign_ok: 60 ret 61 62retzero: 63 clrl r0 64 ret 65 66retmin: 67 movl $0xd0000000,r0 68 ret 69