I’m having an issue with Visual Studio, it doesn’t recognise “byte ptr” in asm. Does anyone know what I should use instead? I use visual studio because I just wanted to do a little asm next to a c++ code to speed things up a little. So could anyone also check the code, because I’m not sure about the return (this is just a test). And does this work for in also for uint?
__declspec(naked) void bewerken(int letter)
{
__asm
{
push ebp
mov ebp, esp
sub esp, 1 // ruimte maken voor 1 variabele van 1 byte
mov byte ptr [eax], [ebp+8]
mov esp, ebp
pop ebp
ret
}
}
int _tmain(int argc, _TCHAR* argv[])
{
char* bYte;
int letter;
printf_s("Voer een letter in:\n");
letter = getchar();
if (letter < 128)
{
__asm
{
push letter
call bewerken
add esp, 4
mov byte ptr bYte, eax
}
}
else
{
printf_s("Te hoog.\n");
}
getchar();
return 0;
}
note: “BYTE PTR” doesn’t compile either
There is no valid addressing mode
mov whatever [eax], [ebp+8]One can
mov al, [ebp+8]ormov ax,[ebp+8]andmov eax,[ebp+8]and alsomov rax,[ebp+0x132220], but also one can move an immediate to an address with immediate offset. That would be the only case, where explicit width attribute is needed:mov byte ptr 0x01,[ebp+8]at least that’s the way it worked in the era of debug.exe…In every other case the width of the operation should be clear.