I am trying to make a simple hello world program in assembly, I use 64 bit Windows and I am calling printf in the assembly code. But it doesn’t work, when I open the compiled program, it doesn’t print anything and just closes. Here’s the code:
<code>; hello.asm
section .data
hello db 'Hello, World!', 0
section .text
global main
extern printf
extern ExitProcess
main:
mov rdi, hello
call printf
mov eax, 0
call ExitProcess
</code>
<code>; hello.asm
section .data
hello db 'Hello, World!', 0
section .text
global main
extern printf
extern ExitProcess
main:
mov rdi, hello
call printf
mov eax, 0
call ExitProcess
</code>
; hello.asm
section .data
hello db 'Hello, World!', 0
section .text
global main
extern printf
extern ExitProcess
main:
mov rdi, hello
call printf
mov eax, 0
call ExitProcess
This is my command to compile the assembly:
nasm -f win64 main.asm -o main.obj
And this is my command to link it:
gcc -o main.exe main.obj -lkernel32 -lmsvcrt