Access violation executing assembly function

36 views Asked by At

The assembly code:

_CODE SEGMENT
PUBLIC my_add_asm_call
my_add_asm_call PROC
    mov eax, 2 // the exception happens here.
    mov ecx, 3
    add eax, ecx
    ret
my_add_asm_call ENDP
_CODE ENDS
END

The C++ code:

extern "C" int my_add_asm_call();

int main()
{
    std::cout << my_add_asm_call();
}

I have not the slightest clue why this is happening, since using the x86_64 "rax" and "rcx" doesn't fix it. I don't really know assembly, as you may guess, but I would like to learn at least a little.

0

There are 0 answers