I'm writing a simply x64 assembly program in Visual Studio. Whenever the program runs, the following exception gets thrown: 0xC0000005: Access violation executing location (memory address). It's strange, because the exception only gets thrown once the code has completely finished executing.
I've narrowed the cause of the exception down to a call to a C++ function from the assembly.
Here's my code:
printNum proto C
.code
main proc
; Do stuff
NoBuzz:
cmp rbp, 0
jne NoNum
mov rcx, rbx
call printNum ; Removing this line prevents the exception
; Do stuff
ret
main endp
end
#include <iostream>
extern "C" void printNum(int Num)
{
std::cout << Num;
}