Thread: int 80h
View Single Post
Old Nov 1st, 2005, 7:29 AM   #4
splyxx
Newbie
 
Join Date: Nov 2005
Posts: 4
Rep Power: 0 splyxx is on a distinguished road
Hi,

http://www.lxhp.in-berlin.de/lhpsysc0.html

There's a lot of stuff at www.linuxassembly.org too. On a side note, I would not perform system calls directly if there's a chance to use libc. Doing so only requires linking with the library itself and the C runtime support module and specifying a runtime linker to use:

/home/splyxx [0]> cat test.asm
extern puts
global main

section .text

msg db 'hello world', 0

main:
        push dword msg
        call puts
        add esp, 4
        mov eax, 0
        ret

/home/splyxx [0]> nasm -f elf test.asm -o test.o
/home/splyxx [0]> ld test.o -o test /usr/lib/crti.o /usr/lib/crtn.o /usr/lib/crt1.o -lc --dynamic-linker /lib/ld-linux.so.2
/home/splyxx [0]> ./test
hello world
/home/splyxx [0]>

(The details may differ if you're using a new Linux system - this one is almost three years old - but you should be able to reverse-engineer what gcc does to link applications. If you link with libc, your assembly code will be portable to FreeBSD, NetBSD, OpenBSD (If you prepend libc functions with a ``_'' character even to a.out-based OpenBSD) and perhaps other x86 systems your assembler runs on.)

In fact you should invoke gcc instead of ld to link your application, unless you're writing your own compiler
splyxx is offline   Reply With Quote