News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

stupid problem with FPU ?

Started by ToutEnMasm, October 13, 2007, 04:35:08 PM

Previous topic - Next topic

ToutEnMasm

Hello,
I try to make work this code who work with C++ (it's a decompiled of a sample).
.data
   DeuxPI DQ  6.2831853071795864 ;0401921fb60000000r   ;   
   QuaranteNeuf   DQ 49.0
                index dd 0
                theta dd 0
               
.code

      mov index,3
      .while(index)
      
      mov eax,index
      mov dword ptr PasseQword,eax
      mov eax,0
      mov dword ptr PasseQword[4],eax
      fld   index  ;don't accept    PasseQword
      fmul   QWORD PTR DeuxPI   
      push 49
      fdiv   dword ptr [esp] ;don't accept qword ptr  QuaranteNeuf
      pop eax
      fstp   DWORD PTR theta       
      fld theta
      fst PasseQword         
      invoke FloatToStr,PasseQword,addr sortie
      invoke MessageBox,hWndParent,ADDR sortie,ADDR tbSelect,MB_OK
      dec index
      .endw

;-----------------------------------------------
I repeat that the loading of the qword index works with c++ sample.
Why ? ,(just return about 0) ???????????????


gabor

Hello!

It looks to me that index is am integer. This would mean that

      fld   index  ;don't accept    PasseQword

and

      push 49
      fdiv   dword ptr [esp] ;don't accept qword ptr  QuaranteNeuf

are not correct.
Use integer load (fild) and integer division (fidv) instead! Like this:

      fild   index

and

      push 49
      fidiv   dword ptr [esp]


QWords are real8 values when using the FPU. This may help you to distinguish the integer and float types.
This should compile and work:

DeuxPI        real8 6.2831853071795864
QuaranteNeuf  real8 49.0

and

fdiv real8 ptr QuaranteNeuf


Greets, Gábor
What

ToutEnMasm

Hello,
In some case use of real8 can be useful , but not always.
I have two differents prog for testing ths,one only for test,say OK,the other is the real one and say no,perhaps is there some init to do before it works.
There is two things strange,PI can be declared as dd or real8,thie run.
finally,i modified it as follow:
Quote
      FLDPI
      fst PasseQword      ;for debugging
      mov arg1,2
      fimul arg1
      fst PasseQword                   ;for debugging   
      fimul index
      fst PasseQword                          ;for debugging
      push 49
      fidiv dword ptr [esp]
      fst PasseQword      ;for debugging
      pop eax
      fstp   theta         ;