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 * @(#)Kfnorm.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(Kfnorm, R6|R5|R4|R3|R2) 19 # clrl r1 20 movl r0,r4 # copy to temporary. 21 jneq inr0 22 movl r1,r5 23 clrl r3 # r3 - pos of m.s.b 24inr1: ffs r5,r6 25 incl r6 26 addl2 r6,r3 27 shrl r6,r5,r5 28 jneq inr1 29 cmpl $0,r3 30 jeql retzero 31 jmp cmpshift 32inr0: movl $32,r3 33inr00: ffs r4,r6 34 incl r6 35 addl2 r6,r3 36 shrl r6,r4,r4 37 jneq inr00 38 39cmpshift: 40 # compute the shift (r4). 41 subl3 r3,$HID_R0R1,r4 42 jlss shiftr # if less then zero we shift right. 43 shlq r4,r0,r0 # else we shift left. 44 subl2 r4,r2 # uodate exponent. 45 jleq underflow # if less then 0 (biased) it is underflow. 46 jmp combine # go to combine exponent and fraction. 47shiftr: 48 mnegl r4,r4 49 shrq r4,r0,r0 # shift right. 50 addl2 r4,r2 # update exponent 51 cmpl r2,$256 52 jgeq overflow # check for overflow. 53combine: 54 andl2 $CLEARHID,r0 # clear the hidden bit. 55 shal $EXPSHIFT,r2,r2 # shift the exponent to its proper place. 56 orl2 r2,r0 57 ret 58 59underflow: 60 clrl r0 61 orl2 $HFS_UNDF,*4(fp) 62 ret 63 64overflow: 65 orl2 $HFS_OVF,*4(fp) 66 ret 67retzero: 68 clrl r0 69 clrl r1 70 ret 71