How to retrieve a qword floating point return value?
Quote
double cvGetCaptureProperty( CvCapture* capture, int property_id );
It will probably be returned in eax:edx but you will have to check to be sure.
corrected: floating point values will be returned on the FPU stack.
Floating-point return values are normally returned on the FPU stack in ST. This might seem like a strange way to return a value, but actually it's very well thought out and flexible. Because the value is stored in the FPU as a REAL10 it retains the maximum possible precision, and the caller can convert the value and store it to memory (as well as perform the essential step of removing it from the FPU stack) as any type that the FPU supports. I don't have OpenCV, so this example uses the CRT sqrt function instead:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
.data
two_r8 REAL8 2.0
rtn_r8 REAL8 0.0
rtn_dq dq 0
rtn_dd dd 0
.code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
invoke crt_sqrt, two_r8
fstp rtn_r8
invoke crt_printf, chr$("%.15f",10), rtn_r8
invoke crt_sqrt, two_r8
fistp rtn_dq
invoke crt_printf, chr$("%I64d",10), rtn_dq
invoke crt_sqrt, two_r8
fistp rtn_dd
invoke crt_printf, chr$("%d",10,10), rtn_dd
inkey "Press any key to exit..."
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
1.414213562373095
1
1
In my quick search, all of the examples that I encountered stored the return value as a 32-bit signed integer. For example:
frame_size.height = (int) cvGetCaptureProperty( . . .
I tried poping the FPU st0 but the result is 0. Also I load the [eax] value as a qword and it return zero, eax value is 3.
Try posting the code that you are using to do the call, get the return value, and display the return value.
Quote
invoke cvGetCaptureProperty,ftest,CV_CAP_PROP_FRAME_WIDTH
; push eax
; fild dword ptr[esp]
fstp FPS
; pop eax
invoke FloatToStr2,FPS,addr buff
invoke lstrlen,addr buff
invoke TextOut,main_screen.DC,0,45,addr buff,eax