logoalt Hacker News

GoblinSlayer10/12/20241 replyview on HN

--- hello_world.asm ---

  bits 64
  default rel

  segment .data
   msg db "Hello world!", 0xd, 0xa, 0

  segment .text
  global main
  extern ExitProcess

  extern printf

  main:
   push    rbp
   mov     rbp, rsp
   sub     rsp, 32

   lea     rcx, [msg]
   call    printf

   xor     rax, rax
   call    ExitProcess
---

nasm -f win64 -o hello_world.obj hello_world.asm

link hello_world.obj /subsystem:console /entry:main /out:hello_world_basic.exe


Replies

rep_lodsb10/12/2024

That's linking to Microsoft's C library in order to use printf. But of course you could do the same thing using just kernel32.dll functions.

show 1 reply