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?
; ------------------------------------------------------------
; 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
; ------------------------------------------------------------
Last edited by va!n on Mon May 15, 2006 4:50 am, edited 1 time in total.
problem solved! now i got the point and i did a very strange mistage DWord and QWord (just a stupid tpye mistake) Here is a working version for such are intersted in ^^
; ------------------------------------------------------------
; PB v4 Win32 API Test by Thorsten Will aka va!n in 05/2006
; ------------------------------------------------------------
;
; Just a small procedure using x86 ASM to return the PI value
; as double. Just only a small inline asm test for PB4 ^^
;
; ------------------------------------------------------------
Procedure.d MyPI()
Protected dReturnValue.d
! fldpi
! fstp qword[p.v_dReturnValue]
! mov eax,[p.v_dReturnValue]
ProcedureReturn dReturnValue
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
; ------------------------------------------------------------