Chinaunix首页 | 论坛 | 博客
  • 博客访问: 135531
  • 博文数量: 24
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 590
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-18 08:29
文章分类

全部博文(24)

文章存档

2011年(1)

2009年(5)

2008年(18)

我的朋友

分类: LINUX

2008-10-23 22:31:09

section .text ;这是我的第一汇编程序
global main   ;主程序
main:
mov eax,4     ;4号调用
mov ebx,1     ;ebx送1表示stdout
mov ecx,msg   ;字符串的首地址送入ecx
mov edx,14    ;字符串的长度送入edx
int 80h       ;输出字串
mov eax,1     ;1号调用
int 80h       ;介绍
msg:
db"Hello World!",0ah,0dh

这下面是编译和运行的过程
[gaowei@localhost nasm]$ ls
hello.com
[gaowei@localhost nasm]$ nasm -f elf hello.com
[gaowei@localhost nasm]$ ls
hello.com  hello.o
[gaowei@localhost nasm]$ gcc -o hello hello.o
[gaowei@localhost nasm]$ ls
hello  hello.com  hello.o
[gaowei@localhost nasm]$ ./hello
Hello World!
阅读(1073) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~