I have a question about nasm and its relationship with C ++. I declare the litte test function as
extern "C" void __cdecl myTest( byte i1, byte i2, int stride, int *width );
and I call it like this:
byte i1 = 1, i2 = 2; int stride = 3, width = 4; myTest( i1, i2, stride, &width );
The method only serves to debug the assembly and to see how the stack pointer is used to get arguments. in addition, the value of the pointer arguments must be set to 7 to figure out how this works. This is done as follows:
global _myTest _myTest: mov eax, [esp+4] ; 1 mov ebx, [esp+8] ; 2 mov ecx, dword [esp+16] ; width mov edx, dword [esp+12] ; stride mov eax, dword [esp+16] mov dword [eax], 7 ret
and compiled through
yasm -f win32 -g cv8 -m x86 -o "$(IntDir)\$(InputName).obj" "$(InputPath)"
and then linked to a C ++ application. In debug mode, everything works fine. the function is called several times and works as expected, whereas in the release mode the function works once, but subsequent program operations fail. It seems to me that something is wrong with the pointers to the stack / frame, near / far, but I am completely new to this topic and need a little help. thanks in advance! a.
source share