On Fri, 25 Mar 2005 [EMAIL PROTECTED] wrote:
> Also might want an exit call on the end.. otherwise it'll keep on executing
> whatever is after the code you load in to memory.. keep reading down a bit
> in
> that article, it mentions this and shows you how to do an exit syscall in
> asm..
>
> ; for the program to properly exit instead of segfaulting right here
> ; ( it doesn't seem to like to fall off the end of a program ), call
> ; a sys_exit
>
> mov eax,1
> mov ebx,0
> int 80h
>
> Joshua Roys
I changed `_start' to `main' because during the linking fase it keeps
complaining about define's.
~: cat prog.asm
section .text ; declaring our .text segment
global _start ; telling where program execution should start
_start: ; this is where code starts getting exec'ed
pop ebx ; get first thing off of stack and put into ebx
dec ebx ; decrement the value of ebx by one
pop ebp ; get next 2 things off stack and put into ebx
pop ebp
mov eax,1 ; exit
mov ebx,0
int 80h
~: nasm -f elf prog.asm
~: gcc prog.o -o prog
prog.o: In function `_start':
prog.o(.text+0x0): multiple definition of `_start'
/usr/lib/crt1.o(.text+0x0): first defined here
/usr/lib/crt1.o: In function `_start':
/usr/lib/crt1.o(.text+0x18): undefined reference to `main'
collect2: ld returned 1 exit status
I'm a bit lost here I guess.. ;-)
J.
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html