Take a number such as $05e4 hex (1508 decimal)
I want to divide it by $0FFF hex (4096 decimal)
with a result of $???? hex (.3681640625 decimal)

Then i want to multiply the result by $01Eh (30 decimal)
for a final result of 11.044921875

I cant seem to make it work in intel asm. my windoze calc can do it, VB can do it... How do i do it in asm?? Dont really need 9 decimal places, somthing close would be ok. Can someone code up a routine for me or show me how to do it?
Help, I am stuck in math MuD.

SD.
Posted on 2001-07-30 10:35:57 by SirDan
IF you want decimal places in your answer then you have to use the FPU. Heres a simple example.

.data
Val1 dd 1508.0f
Val2 dd 4096.0f
Val3 dd 30.0f

.data?
Ans dd ?

.code
finit ; Prepare FPU
fld Val1 ; Load 1508 onto FPU stack
fdiv Val2 ; Divide by 4096
fmul Val3 ; Multiply by 30
fstp Ans ;Place answer in Ans

Find two basic tutorials for the FPU here
Posted on 2001-07-30 12:24:16 by Eóin
Thats great thanks!!

SD
Posted on 2001-07-31 04:02:50 by SirDan
you can do it without a FPU and with decimal places, but in that case you have to "learn" your computer basic math like you did in your very first year at school. In Europe we call it basic school. (around 6-7-8 years old)

exp:                1 2 . 3 4
                  x  1 7
                  -- -----------------
                      8  6  3  8
      +          1  2  3  4  0
      ----------------------------- add the stuff and place your decimal point at the right place. Every decimal digit here must be one in memory too.

have fun
Posted on 2005-11-14 18:27:59 by raidu
Just in case Eóin's link to tutorials go crazy like it did for me, you can have access to the following without any risk:

http://www.ray.masmcode.com/index.html#fputut

If you don't want to go to the trouble of learning how to use the FPU yet, you can always use the library of functions available from the same site.

Raymond
Posted on 2005-11-16 22:07:41 by Raymond