Apologies if this is trivial - i'm familiar with code but new to assembler and can't find many beginner-friendly resources online.
I want to get a simple print statement to run in a nasm 64-bit environment. I'm pulling in code that was originally working on 32-bit, but I can't figure out why it doesn't work here.
I've tried altering registers to use for example, rax instead of eax - from what I understand replacing the 'e' with an 'r' corresponds to the 64-bit register counterpart
;nasm 2.11.08
section .text
global _start
_start:
call func
mov eax, 1
mov ebx, 0
int 0x80
func:
mov ebp, esp ; ebp is the base pointer - holds the value of the top of the stack
sub esp, 2 ; removing 16 bits (2 bytes) from our stack pointer. Means allocating 2 bytes on the stack
mov [esp], byte 'H'
mov [esp+1], byte 'i'
mov eax, 4 ; sys write call
mov ebx, 1
mov ecx, esp
mov edx, 2
int 0x80
mov esp, ebp ; puts stack back into state where it was
ret
I compile this in a 64-bit environment - this website to be specific: https://rextester.com/l/nasm_online_compiler
However, I get the following error
Invalid memory reference (SIGSEGV
What I want see the output 'Hi' printed to the console. Any guidance is appreciated! Or simply resources that I can use to understand registers better
Cheers