I learned assembly starting at x64 architecture, now I'm a bit confused about x86 architecture.
When looking at x86 syscall tables on the internet, the arguments for the syscalls are (just like x64) to be put in various registers.
E.g. the argument "Exit Code" for "sysexit" should be put into ebx.
global _start
section .text
_start:
mov ebx, 42
mov eax, 1
int 0x80
echo $?
42
That works fine.
However I follow an online course where they keep putting syscall arguments onto the stack.
global _start
section .text
_start:
mov eax, 1
push 42
int 0x80
echo $?
0
That doesn't work for me.
I also tried several assemblers (nasm, gcc), tried to put esp into ebx (cause I've seen that in other 32bit assembly code, after they pushed the arguments onto the stack they saved the stack pointer into ebx) - when I did that I got "44" as exit code, weirdly.
Then I went searching and found there several different calling convetions, CDECL, FASTCALL, etc.. this is pretty confusing tbh.
How can I get 32bit sysexit work in assembly while pushing it's argument onto the stack?