I tried to code something in assembly x86 on windows 11 and then assemble it with nasm. The programm should output “Hello World”.

section .data
    msg db 'Hello World', 0x0A
    msg_len equ $ - msg

section .text
    global _start

    mov eax, 4
    mov ebx, 1
    mov ecx, msg
    mov edx, msg_len
    int 0x80

    mov eax, 1
    xor ebx, ebx
    int 0x80

This programm then gets assembled into an .obj file:
nasm -fwin32 hello_world.asm

After that, i tried to convert it into an executable:
gcc hello_world.obj

As soon as I enter the gcc command, it displays an error:

c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status

I’m new to assembly, please help me. Also, I’ve copied a Hello World programm from the internet into VS code and assembled it into an executable, and it worked perfectly fine. As far as I understand, the problem is likely to be within my code, I just can’t find it.

New contributor

Felix Hötzendorfer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.