PB4 Win32 - using ASM and doubles problem (solved)
Posted: Mon May 15, 2006 2:52 am
I am working on some stuff and i am trying/playing to get some ASM routines correctly working. Here is a small procedure using x86 ASM for getting the value of PI. Using double as ReturnValue would be nice instead using floats as ReturnValue. So i have declared the Procedure as double by using Procedure.d! Inside the procedure i am using the protected variable fReturnValue.f - as long as declaring this as float, i get a ReturnValue! But when i try to set the fReturnValue.d as double, i get everytime a zero result! If someone can show me my mistake i would be very happy. Or does it is still a hidden v4 bug?
Code: Select all
; ------------------------------------------------------------
; PB v4 Win32 API Test by Thorsten Will aka va!n in 05/2006
; ------------------------------------------------------------
;
; I am trying to return the value of PI! Storing the value
; to the variable fReturnValue.f (defined as float) works
; but not really correct...
;
; Trying to define the variable fReturnValue.d (as double),
; for handling a more correct PI result does not work and
; returns only zero values (my mistake or a hidden bug?)
;
; ------------------------------------------------------------
Procedure.d MyPI()
Protected fReturnValue.f ; Change this to .d (double)
! fldpi ; and test it
! fstp dword[p.v_fReturnValue]
! mov eax,[p.v_fReturnValue]
Debug fReturnValue
ProcedureReturn fReturnValue
EndProcedure
Debug "---- Using Floats ----"
fTest1.f = MyPi()
Debug fTest1.f
Debug "---- Using Doubles ----"
dTest2.d = MyPi()
Debug dTest2.d
Debug "" ; ==================================================
Debug "---- #PI using Float ----"
fTest3.f = #PI
Debug fTest3.f
Debug "---- #PI using Doubles ----"
dTest4.d = #PI
Debug dTest4.d
; ------------------------------------------------------------