I am writing a hello world program for linux x86_64 using GAS assembler and here is my code in AT&T syntax.
#.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
This works and prints "hello world". Here is intel syntax:
.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
This compiles and runs fine but does not print "hello world". I am assuming the mistake is in mov rsi, msg
? If so, what is the correct syntax?