Reputation: 123
I want to read command line arguments when an assembly program is run. Do I have to use sys_read
or something else?
I know how to access data using things like scanf. For instance:
mov eax, 3
mov ebx, 1
mov ecx, msg
mov edx len
int 0x80
What I'm looking for, though, are the command line arguments. When I execute ./a.out 45 23
I want to get access to the '45' for example.
And so, if anybody have a page where the unixstd.h defined... I would be grateful.
Upvotes: 1
Views: 109
Reputation: 123
Accessing command line arguments under ELF32 Linux is available through the stack:
mov eax, [esp+8]
mov ebx, [eax]
mov ecx, offset msg
mov [ecx], ebx
Credit to @Jester for his answer in the comments!
Upvotes: 3