sapphire/test.asm

27 lines
506 B
NASM

format ELF64 executable 3
; Assembly generated by the Sapphire compiler.
segment readable executable
entry start
strlen: ; -- length of null-terminated string in rdi --
xor rax, rax
mov rcx, -1
cld
repne scasb
mov rax, rcx
add rax, 2
neg rax
ret
print: ; -- print null-terminated string in rdi --
mov rsi, rdi
call strlen
mov rdx, rax
mov rdi, 1
mov rax, 1
syscall
ret
start:
; -- exit with code 0 --
mov rax, 60
xor rdi, rdi
syscall