标签:style blog class code tar ext
.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
.data
msg:
.ascii "hello,world\n"
len=.-msg
.ascii "after hello\n"
len2=.-msg我们来看代码段部分,.data表示一个代码段的开始,msg:标号仅仅给编译器看的,它只代表当前地址。len=.-msg得到数据段第一个字符串长度,同理len2是第一个字符串和第二个字符串长度之和。_start代表as汇编程序的默认入口。movl $msg,%ecx,将标号代表的地址放到ecx中。上述程序输出:hello,world。如果把代码段movl $len,%edx改成 movl $len2,$edx,输出如下:
hello,world
after,hello
参考文章:
http://www.cnblogs.com/justinzhang/archive/2012/02/20/2360513.html
as编写hello,world,布布扣,bubuko.com
标签:style blog class code tar ext
原文地址:http://blog.csdn.net/getnextwindow/article/details/25076585