This code is very simple and I get a seg error on my x86_64 Linux system. It bothers me very much. Just start with asm, please be patient!
Assembled with NASM nasm -f elf64 test.asm
related to ld -o test test.o
SECTION .text GLOBAL _start _start: ; print name mov eax,4 ; sys_write mov ebx,1 ; stdout mov ecx,name ; start address of name mov edx,1 ; length int 80H ; syscall ; exit program mov eax,1 ; sys_exit mov ebx,0 ; success int 80H ; sys_call SECTION .data name DB 'R'
My car: Gentoo x86_64 nomultilib! I compiled my own kernel without IA32 emulation. I had to say that my system is only a 64-bit system. Are this attribute errors that I get?
$ uname -a Linux rcepeda 4.4.1-2-ARCH
Decision
use 64-bit registers and 64-bit Linux manager
use syscall (not int 80H).
Thanks Nate and Michael
32-bit SYSCALL Linux table
64-bit SYSCALL Linux table
SECTION .text GLOBAL _start _start: ; print name mov rax,1 ; sys_write mov rdi,1 ; stdout mov rsi,name ; start address of name mov rdx,7 ; length syscall ; exit program mov rax,60 ; sys_exit mov rdi,0 ; success syscall SECTION .data name DB "Rafael",10
.
rafael@rcepeda ~/asm $ ./a.out Rafael