1. Just call puts by
- no need to change any registers.
2. In x86 32bit programming, the cdecl calling convention (or however you want to call it) is used which means
passing arguments over the stack (last one first = right to left), you (the caller) are responsible for saving eax, ecx and edx on the stack and you get your return value over eax. You also have to clean the stack, i.e. remove the arguments you have pushed on it.
Example:
Code: Select all
; int some_function(char* a, int b);
extern some_function
test:
mov eax, some_important_value ; save some important value in eax
push eax ; secure eax for ourselves - no need if we don't care about eax
push second_argument ; you can actually pass a variable, no need to lea first
push first_argument
call some_function ; call the function
mov edx, eax ; somehow use the return value if you need it
add esp, 8 ; remove our arguments from the stack
pop eax ; and get eax back
ret
PS: Sorry for the badly aligned comments.
Note that this only applies to x86 (32 bits). In AMD64 (or however you want to call it), the AMD64 ABI is used which is really different - if you want to support Long Mode one day.