lnlidawei

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

[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

 

posted on 2024-11-18 05:01  lnlidawei  阅读(5)  评论(0编辑  收藏  举报