I have the following x86-64 code, which I can run on OSX Yosemite:
global _main
extern _exit
extern _puts
DEFAULT REL
section .data
putsmsg: db 'Puts message...',0
another: db 0
section .text
_main:
push rbp
mov rbp, rsp
; print a string using PUTS
lea rdi, [putsmsg]
call _puts
; call EXIT(0) c function
mov rdi, 0
call _exit
I compile, link, and run as follows (where the source is a.asm):
nasm -f macho64 a.asm ; gcc a.o -o a.bin ;./a.bin
It does not print the message 'Puts message...', whereas it does print the message if I simply comment out the line containing the label 'another'. What is going wrong here? Why doesn't it print the correct string when I have the other initialized data line?