freebsd at&t 汇编 hello world

.section .data //数据段
  msg: .ascii "hello world\n\0"
.set len,.-msg    //得到字符串长度
.section .text
.globl _start  //入口
  _start:  
  push $len  
  pushl $msg
  pushl $0x01
  pushl $0x00
  movl $0x04,%eax
  int $0x80
  pushl %eax
  pushl $0x00
  movl $01,%eax
  int $0x80

使用as编译链接

$as hello.s -o hello.o
$ld hello.o -o hello.bin
$./hello.bin

posted @ 2013-07-01 21:58  icheng123  阅读(334)  评论(0编辑  收藏  举报