Subject: Re: broken KA690?
To: Hugh Graham <hugh@openbsd.org>
From: Lord Isildur <mrfusion@umbar.vaxpower.org>
List: port-vax
Date: 07/15/2001 15:25:24
whoops! need to decrement by a bigger value indeed!!
it was all fine and dandy til i tried compiling the math library with
it..
there was a 10E20 constant somewhere in the src, and the compiler had to
slog through it, and after i heard the disk stop grinding for an eerily long
time, i went over to see it happily churning through about 10 billion
iterations of that loop.. not good! :)
here is what should be a much better version, it gets right down to what
needs to be decremented. it could be made even shorter, i will do that once
i sit down and think about it.. this below is a gross hack but it is better
than the even grosser one before!
isildur
/* new version */
ENTRY(modf, 0)
cvtdl 4(ap),r2 # get the integer part out
jvs 1f # integer overflow
cvtld r2,*12(ap) # put it in float format, in dest
subd3 *12(ap),4(ap),r0 # put fraction in r0
ret
1:
movd 4(ap),-8(fp) #copy original value
extzv $7,$8,4(ap),-20(fp) #get exponent and sign bit from orig
ashl $-7,-20(fp),-20(fp) #kick it down for a subtraction
decl -20(fp) #subtraction
ashl $7,-20(fp),-20(fp) #kick it back up to its place
movd $0f1.0,-16(fp) #1.0, floating
bisl2 -24(fp),-16(fp) #fast floating multiply
subd2 -16(fp),-8(fp) #decrement it to be close to 1
cvtdl -8(fp),-24(fp) #convert to integer
cvtld -24(fp),-16(fp) #get the remaining integer part
subd3 -16(fp),-8(fp),r0 #put fraction in r0
subd3 r0,4(ap),*12(ap) #put integer component back
ret