全部博文(11)
分类: LINUX
2009-12-19 14:29:02
#AT&T assemble , Hello World
.section .data
string:
.ascii "Hello World!\n"
.section .text
.globl _start
_start:
nop #cpu do nothing, this insctruction write for debug with gdb
#the follow 5 lines is: write(int file_descriptor, void *buffer, size_t length)
movl $4, %eax #Linux soft interrupt, call number in eax, 4 is for system-call write
movl $1, %ebx #file descriptor in ebx, stdout's file descriptor is 1
movl $string, %ecx #buffer in ecx, this line move string's address to ecx
movl $13, %edx #buffer's size in edx
int $0x80 #Linux soft interrupt
#the follow 3 lines is: exit(int status_code)
movl $1, %eax #system call: exit
movl $0, %ebx #status code in ebx
int $0x80 #Linux soft interrupt
|