美文网首页
汇编语言的helloworld

汇编语言的helloworld

作者: 一路向后 | 来源:发表于2021-02-03 21:52 被阅读0次

1.源码实现

#hello.s
.data
        msg : .string "Hello, world!\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

2.编译源码

$ gcc -c hello.s
$ ld -o hello hello.o

3.执行程序

$ ./hello
Hello, world!

相关文章

网友评论

      本文标题:汇编语言的helloworld

      本文链接:https://www.haomeiwen.com/subject/thzmtltx.html