Files
pl/hello.asm

35 lines
605 B
NASM

format ELF64
section '.text' executable
extrn 'putchar' as __putchar
putchar = PLT __putchar
public main
main:
; allocate space for locals (a and b: 4 bytes each → 8 bytes total)
push rbp
mov rbp, rsp
sub rsp, 8
; local a = 34 → stored at [rbp - 4]
mov dword [rbp - 4], 34
; local b = 35 → stored at [rbp - 8]
mov dword [rbp - 8], 35
; compute a + b
mov eax, [rbp - 4]
add eax, [rbp - 8]
; call putchar(a + b)
; SysV: first integer arg → EDI
mov edi, eax
call putchar
; return 0 from main
mov eax, 0
leave
ret