💾 Archived View for thrig.me › software › assembly › helloworld.asm captured on 2024-03-21 at 15:56:53.

View Raw

More Information

⬅️ Previous capture (2023-12-28)

-=-=-=-=-=-=-

; AMD64 OpenBSD 7.4 NASM 2.16.01
;   nasm -f elf64 helloworld.asm -o helloworld.o
;   ld -nopie -static helloworld.o -o hw.ld
;   ld.bfd -m elf_x86_64_obsd -nopie helloworld.o -o hw.bfd

BITS 64

%define stdout    1
%define sys_exit  1
%define sys_write 4

section .note.openbsd.ident note
    align 2
    dd 8, 4, 1
    db 'OpenBSD',0
    dd 0
    align 2

section .data
    msg  db "Hello world!",10
    .len equ $-msg

section .text
global  _start
_start:
    mov rax,sys_write
    mov rdi,stdout
    mov rsi,msg
    mov rdx,msg.len
    syscall

    mov rax,sys_exit
    xor rdi,rdi
    syscall