Hello.
Im quite new in this and i havent worked before with floating point operatoions before , therefore could someone show me snippet code
how do i divide two DWORD values from memory with floating point result?
Thanks in advanced
.data
i1 SDWORD 1234
i2 SDWORD 10
i3 QWORD 12345678912345
f1 REAL4 ?
d1 REAL8 ?
.code
; f1 = i1 / i2
fild i1
fidiv i2
fstp f1
; d1 = i3 / i2
fild i3
fidiv i2
fstp d1
The FPU doesn't support unsigned data types -> SWORD,SDWORD and SQWORD
.DATA
Num1 DD 3
Num2 DD 12
.DATA?
Result REAL4 ?
.CODE
FILD Num1
FILD Num2
FDIV ST(1), ST(0) ;devide Num1 by Num2
FSTP Result ; store the result as a REAL4
Qword was quicker than I was, I was still trying to figure out MASM register names :)
If you are really interested in learning and doing it on your own, you can find a tutorial at:
http://www.ray.masmcode.com/fpu.html
Be sure to read the first two chapters. If you don't have such an interest, you could always use the FPU library available from the same link. It comes with an extensive help file and all the source code for each of the modules.
One of the functions in that library is for converting back from floats to ascii, which can be helpful until you decide to code your own. :dazzled: