[asm] as - linux64
1 code
1 [root@rocky:src]# cat hello64.as
2 # filename = hello64.as
3
4
5 .data
6 msg : .string "Hello, World!\n"
7 len = . - msg
8
9
10 .text
11 .global _start
12
13 _start:
14 movq $len, %rdx
15 movq $msg, %rsi
16 movq $1, %rdi
17 movq $1, %rax # 64bit_sys_write=1
18 syscall
19
20 movq $0, %rdi
21 movq $60, %rax # 64bit_sys_exit=60
22 syscall
23 [root@rocky:src]#
24 [root@rocky:src]#
25 [root@rocky:src]# as -o hello64.o hello64.as && ld -s -o hello64 hello64.o && ./hello64
26 Hello, World!
27 [root@rocky:src]#
28 [root@rocky:src]#
2 compile, link, execute
[root@rocky:src]# as -o hello64.o hello64.as && ld -s -o hello64 hello64.o && ./hello64
Hello, World!
[root@rocky:src]#
[root@rocky:src]#
3. reference
1) AT&T汇编 - https://www.jianshu.com/p/1b4703410ebe
2) Linux系统64位AT&T系统调用汇编指令syscall - https://blog.csdn.net/qq_42108074/article/details/132804264
本文由 lnlidawei 原创、整理、转载,本文来自于【博客园】; 整理和转载的文章的版权归属于【原创作者】; 转载或引用时请【保留文章的来源信息】:https://www.cnblogs.com/lnlidawei/p/18551519