Working with float values in MASM and getting them into variables

274 views Asked by At

I am trying to get the value from ST(0) register and get it stored in the variable. But my attempts are failing horribly. Here is part of code, where I am interacting with the float values. The correct result is stored in the ST(0) register, but how do I get it out of it in a variable? With this current code, I get the value -

8256657931607403600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000

Which is better than nothing, but pretty horrible too, because it needed to be 1.5 xD

    fldz
    fild [FirstEndSum]
    fild [SecondEndSum]
    
    fdivp st(1),st
    fstp [FirstRoot]
    
    push offset FirstRoot      ; 1.5 from ST(0)
    push offset FormatString   ; From Data: FormatString    db      "%f",0
    call printf
    pop eax
0

There are 0 answers