#this is a 'hello world' program
.section .data
output: #字符串的起始地址
.ascii "hello world!\n" #字符串内容
.section .text
.globl _start #全局访问标识符
_start: #程序入口标志
#利用软中断调用内核函数,打印信息
movl $4, %eax #系统调用值
movl $1, %ebx # 终端类型,1为标准输出
movl $output, %ecx #字符串地址
movl $13, %edx #字符串长度
int $0x80 #调用软中断
#干净的退出程序
movl $1, %eax #系统调用值
movl $0, %ebx #返回值
int $0x80
汇编及链接程序
as -o hello.o hello.s
ld -o hello hello.o
执行:./hello
.section .data
output: #字符串的起始地址
.ascii "hello world!\n" #字符串内容
.section .text
.globl _start #全局访问标识符
_start: #程序入口标志
#利用软中断调用内核函数,打印信息
movl $4, %eax #系统调用值
movl $1, %ebx # 终端类型,1为标准输出
movl $output, %ecx #字符串地址
movl $13, %edx #字符串长度
int $0x80 #调用软中断
#干净的退出程序
movl $1, %eax #系统调用值
movl $0, %ebx #返回值
int $0x80
汇编及链接程序
as -o hello.o hello.s
ld -o hello hello.o
执行:./hello