When I am uncertain about the assembly code instructions, I write a snippet of code in C or C++ and then look at the assembly code listing. I did that with this. This code has a simple function and a pointer to it which is called. Here is the assembly code listing :
?DoFunctionTest@@YAXXZ PROC ; DoFunctionTest
; 237 : {
$LN3:
push rdi
sub rsp, 64 ; 00000040H
mov rdi, rsp
mov ecx, 16
mov eax, -858993460 ; ccccccccH
rep stosd
; 238 : double x = 16.612;
movsd xmm0, QWORD PTR __real@40309cac083126e9
movsd QWORD PTR x$[rsp], xmm0
; 239 : dblfunc df = factor;
lea rax, OFFSET FLAT:?fac@@YANN@Z ; fac
mov QWORD PTR df$[rsp], rax
; 240 : double result = ( *df )( x );
movsd xmm0, QWORD PTR x$[rsp]
call QWORD PTR df$[rsp] ; the actual function call is here
movsd QWORD PTR result$[rsp], xmm0
; 241 : trace( _T( "DoFunctionTest() - result is %.3f\n" ), result );
movsd xmm1, QWORD PTR result$[rsp]
movq rdx, xmm1
lea rcx, OFFSET FLAT:$SG255887
call ?trace@@YA_NPEB_WZZ ; trace
; 242 : }
That was the assembly code in debug Unicode 64-bit mode for this code:
double fac( double x )
{
return 1.0 + x;
}
typedef double ( *dblfunc )( double x );
void DoFunctionTest()
{
double x = 16.612;
dblfunc df = fac;
double result = ( *df )( x );
trace( _T( "DoFunctionTest() - result is %.3f\n" ), result );
}