I'm working through some of the tutorials on http://www.ibm.com/developerworks/linux/library/l-gas-nasm/index.html to familiarize myself with x86/x64. This tutorial code compiles and runs without a hiccup using the provided code, which uses AT&T syntax:
.global main
.text
main: # This is called by C library's startup code
mov $message, %rdi # First integer (or pointer) parameter in %edi
call puts # puts("Hello, World")
ret # Return to C library code
message:
.asciz "Hello, World" # asciz puts a 0x00 byte at the end
However, when I convert this code to Intel syntax, I get a "Segmentation fault" error.
.intel_syntax noprefix
.global main
.text
main: # This is called by C library's startup code
mov rdi, message # First integer (or pointer) parameter in %edi
call puts # puts("Hello, World")
ret # Return to C library code
message:
.asciz "Hello, World" # asciz puts a 0x00 byte at the end
I'm not familiar with x86, so perhaps I'm missing something. Any ideas?