I have been trying to use the FPULIB and one some valid valuse it is erroring on like

CCCC0441

that converts to 8.2999992........ using Base convertor from hexworkshop

but in the FPULIB it generates and error

I wondering why if anyone could explain..

oh and im pushing the var into the FPU with

FLD VAR


Edit in:
well the number looks to be an infinite but cant the FPU clip off at a certain point and round it up to 8.3
Posted on 2003-07-31 12:22:10 by devilsclaw
i been debuging the FPULib and since i dont know a darn thing about Floats really i will just tell you what i have seen..

;----------------------------------------------------------------------------------------
; multiply the number by the power of 10 to generate required integer and store it as BCD
;----------------------------------------------------------------------------------------

.if tempdw != 0
fild tempdw
fldl2t
fmul ;->log2(10)*exponent
fld st(0)
frndint ;get the characteristic of the log
fxch
fsub st,st(1) ;get only the fractional part but keep the characteristic
f2xm1 ;->2^(fractional part)-1
fld1
fadd ;add 1 back
fscale ;re-adjust the exponent part of the REAL number
fxch
fstp st(0) ;get rid of the characteristic of the log
fmul ;->16-digit integer
.endif

fbstp bcdstr ;->TBYTE containing the packed digits
fstsw stword ;retrieve exception flags from FPU
fwait
test stword,1 ;test for invalid operation
jnz srcerr ;clean-up and return error

it test tempdw
and in this case it has the value 80000010
Posted on 2003-07-31 13:13:53 by devilsclaw
ok explain this to me please...

after i run the FPU Float to ASCII proc do i have to clear the fpu or something because it converts that number right

the first time it runs it but the second time it runs into the value it errors...
Posted on 2003-07-31 14:30:22 by devilsclaw
well i did some search on the board how to clear the FPU and i found FINIT and i run that after the command and it seems to work fine..
Posted on 2003-07-31 14:44:47 by devilsclaw
The FPU has its own set of rules in order to use it properly. You may want to have a look at a new tutorial (still in progress but almost completed) at:

http://www.masmforum.com/website/tutorials/fptute/index.html

It has a chapter on the FPU internals and one on the format of floating point numbers and their memory representation.

As for the Fpulib, the general design assumption was that its functions would be used for all FPU operations. Each of the functions clears the FPU unless one of the parameters is specified to be present in the TOP register. Each function also exits with no more than one value left on the FPU and it must be used with the following function; otherwise, it gets trashed.

That was to insure that the FPU would never get overfilled. However, a function such as the FpuFLtoA would leave the value to be converted on the FPU if the function is called with that value specified as being already on the FPU. If it does not get cleared and other values keep getting loaded for conversion, the FPU gets filled rapidly and an error is generated.

Feel free to ask any question.

Raymond
Posted on 2003-07-31 23:10:51 by Raymond
thanks i will look at it...
Posted on 2003-07-31 23:44:57 by devilsclaw