How come this (https://www.mycompiler.io/new/asm-x86_64):
section .data
msg db "Hello world!", 0ah
section .text
global _start
_start:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, 13
syscall
mov rax, 60
mov rdi, 0
syscall
and this (https://www.tutorialspoint.com/compile_asm_online.php):
section .text
global _start ;must be declared for using gcc
_start: ;tell linker entry point
mov edx, len ;message length
mov ecx, msg ;message to write
mov ebx, 1 ;file descriptor (stdout)
mov eax, 4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax, 1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string
do the exact same thing, but when I switch the codes between the two compilers, it reads both 'Instructions not supported in 32-bit mode' (1st compiler to 2nd) and 'signal: bad system call (core dumped)' (2nd compiler to 1st)
When I try to convert the 2nd compiler to 64 bits mode with 'bits 64', it reads: '64-bit unsigned relocation zero-extended from 32 bits [-w+zext-reloc] Segmentation fault (core dumped)'