I want to create a function that receives a 1 byte argument. But I am reading that in x86 I can only push 2 or 4 bytes onto the stack. So should I expect a 2 bytes argument to be passed to my function and then extract my 1 byte? Is this is how to pass a 1 byte argument to my function:
push WORD 123
The stack must be aligned. If you make 16 bit real mode program, the stack must be aligned on 16 bits. If you make 32 bit, protected mode program the stack must be aligned on 32 bits.
But you don't need to pass exactly 1 byte to the function. Just push 16/32 bits and use only the lowest 8 of them in the function. Something like this:
use32 proc MyFunc, .arg32, .arg16, .arg8 begin mov eax, [.arg32] mov bx, word [.arg16] mov cl, byte [.arg8] ret endp Main: push ecx ; CL is arg8 push ebx ; BX is arg16 push eax ; EAX is arg32 call MyFunc ; Or shortly: stdcall MyFunc, eax, ebx, ecx