思路:
代码如下:
$ cat hello.s
#hello.s My first GAS program
.section .data
str:
.ascii "Hello, world!\n"
.section .text
.globl _start
_start:
movl $4, %eax
movl $1, %ebx
movl $str, %ecx
movl $14, %edx
int $0x80
movl $1, %eax
movl $0, %ebx
int $0x80
在centos上编译连接和执行:
$as -o hello.o hello.s
$ld -o hello hello.o
$./hello
Hello, world!
$
成功!