1*45761Sbostic/*- 2*45761Sbostic * Copyright (c) 1985 The Regents of the University of California. 3*45761Sbostic * All rights reserved. 4*45761Sbostic * 5*45761Sbostic * This code is derived from software contributed to Berkeley by 6*45761Sbostic * Computer Consoles Inc. 7*45761Sbostic * 8*45761Sbostic * %sccs.include.redist.c% 9*45761Sbostic * 10*45761Sbostic * @(#)Kcvtfl.s 7.1 (Berkeley) 12/06/90 11*45761Sbostic */ 1224136Ssam 1345701Sbostic#include "../math/fp.h" 1425693Ssam#include "../tahoe/SYS.h" 1525664Ssam 1624136Ssam .text 1725664SsamENTRY(Kcvtfl, R5|R4|R3|R2) 1824136Ssam clrl r1 1924136Ssam clrl r4 # r4 - negative flag. 2024136Ssam clrl r2 # r2 - exponent. 2124136Ssam movl 4(fp),r0 # fetch operand. 2224136Ssam movl r0,r5 # need another copy. 2324136Ssam jeql retzero # return zero. 2424136Ssam jgtr positive 2524136Ssam mnegl r0,r0 2624136Ssam jvs retmin # return minimum integer. 2724136Ssam incl r4 # remember it was negative. 2824136Ssam movl r0,r5 # remember the negated value. 2924136Ssam # 3024136Ssam #Compute exponent: 3124136Ssam # 3224136Ssampositive: 3324136Ssam ffs r0,r1 3424136Ssam incl r1 3524136Ssam addl2 r1,r2 3624136Ssam shrl r1,r0,r0 3724136Ssam jneq positive # look for more set bits. 3824136Ssam # 3924136Ssam #we have the exponent in r2. 4024136Ssam # 4124136Ssam movl r5,r0 # r0 will hold the resulting f.p. number. 4224136Ssam # 4324136Ssam #Shift the fraction part to its proper place: 4424136Ssam # 4524136Ssam subl3 r2,$HID_POS,r3 4624136Ssam jlss shiftr # if less then zero we have to shift right. 4724136Ssam shll r3,r0,r0 # else we shift left. 4824136Ssam jmp shifted 4924136Ssamshiftr: 5024136Ssam mnegl r3,r3 5124136Ssam shrl r3,r0,r0 5224136Ssamshifted: 5324136Ssam andl2 $CLEARHID,r0 # clear the hidden bit. 5424136Ssam shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place. 5524136Ssam orl2 $EXPSIGN,r2 # set the exponent sign bit(to bias it). 5624136Ssam orl2 r2,r0 # combine exponent & fraction. 5724136Ssam bbc $0,r4,sign_ok # do we have to set the sign bit? 5824136Ssam orl2 $SIGNBIT,r0 # yes... 5924136Ssamsign_ok: 6024136Ssam ret 6124136Ssam 6224136Ssamretzero: 6324136Ssam clrl r0 6424136Ssam ret 6524136Ssam 6624136Ssamretmin: 6724136Ssam movl $0xd0000000,r0 6824136Ssam ret 69