Netwide Assembler (NASM) >> Assembly (x86)

hello, world! (int 0x80)


參考資訊:
1. syscall
2. Assembly-HOWTO

System Call

NRsyscall nameeaxarg0(ebx)arg1(ecx)arg2(edx)
1exit1int error_code
4write4unsigned int fdconst char *bufsize_t count

main.s

    global _start

    section .data
msg db "hello, world!", 10
len equ $ - msg
   
    section .text
_start:
    mov eax, 4
    mov ebx, 1
    mov ecx, msg
    mov edx, len
    int 80h
 
    mov eax, 1
    mov ebx, 0
    int 80h 

編譯、執行

$ nasm -f elf32 main.s
$ i686-linux-gnu-gcc main.o -o main -static -nostdlib
$ qemu-i386 ./main
    hello, world!


返回上一頁