How do you make use of command-line arguments? (asm/linux)
Posted: Fri Dec 07, 2007 11:55 am
Hi everyone. I'm in the process of learning asm for x86 on linux, using gas. I'm experimenting with what I know and I'm curious about how I could say, run ./example [argument] and have the program work with that argument.
I tried experimenting to see if the argument is passed to a register, and also in the previous stack frame but I haven't had any luck yet. Will this be more complex than I think it is?
After running I check with echo $? to see the return value. An argument passed while running this does change the return, but not with my value.
I'm just experimenting and having fun, so if I'm doing anything silly, keep that in mind
I tried experimenting to see if the argument is passed to a register, and also in the previous stack frame but I haven't had any luck yet. Will this be more complex than I think it is?
Code: Select all
#PURPOSE: Simple program that exits and returns a value to the kernel
#VARIABLES:
# %eax holds the system call number
# %ebx holds the return status
#
.section .data
.section .text
.globl _start
_start:
movl 8(%esp), %ebx #copy data from above stack frame into %ebx
movl $1, %eax #prepare kernel exit call
int $0x80 #exit
I'm just experimenting and having fun, so if I'm doing anything silly, keep that in mind