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