您的位置:首页 > 运维架构 > Linux

linux 下at&t语法的汇编之hello world!!

2012-09-11 21:42 387 查看
linux 32位汇编(hello world;)


#hello.s
.data  #data
msg : .string "Hello ,As Compliner!! Linux\n"
len = . - msg
.text
.global _start

_start :
movl $len, %edx
movl $msg, %ecx
movl $1, %ebx
movl $4, %eax
int $0x80

movl $0, %ebx
movl $1, %eax
int $0x80


  linux 64 位汇编:

#hello.s
.data  #data
msg : .string "Hello ,As Compliner!! Linux\n"
len = . - msg
.text
.global _start

_start :
movq $len, %rdx
movq $msg, %rcx
movq $1, %rbx
movq $4, %rax
int $0x80

movq $0, %rbx
movq $1, %rax
int $0x80


  编译 :

$:as -o hello.o hello.s

$:ld -o hello hello.o

$:chmod a+x ./hello

$:./hello
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: