我正在使用 GAS 汇编器为 linux x86_64 编写一个 hello world 程序,这是我的 AT&T 语法代码。
#.intel_syntax noprefix
.section .data
msg:
.ascii "hello world\n"
.section .text
.globl _start
_start:
movq $1, %rax
movq $1, %rdi
movq $msg, %rsi
movq $12, %rdx
syscall
movq $60, %rax
movq $0, %rdi
syscall
这有效并打印“hello world”。这是英特尔语法:
.intel_syntax noprefix
.section .data
msg:
.ascii "hello world\n"
.section .text
.globl _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 12
syscall
mov rax, 60
mov rdi, 0
syscall
这编译并运行良好,但不打印“hello world”。我假设错误在mov rsi, msg
?如果是这样,正确的语法是什么?