NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: Lucas Nunes on February 27, 2010, 01:44:47 AM

Title: Problems with NASM
Post by: Lucas Nunes on February 27, 2010, 01:44:47 AM
Hello!
I'm noob in NASM. Well, my biggest problem is a basic. I can't "compile".
I tried very Hello World programs that I found on the internet.
I am almost abandoning the NASM...  :-[

So please, someone can make a Hello World program for Windows?
How do I build?

Title: Re: Problems with NASM
Post by: Mathi on February 27, 2010, 06:02:39 AM
http://mathimaaran.angelfire.com/helloworld_tutorial.htm (http://mathimaaran.angelfire.com/helloworld_tutorial.htm)
Title: Re: Problems with NASM
Post by: Bryant Keller on February 27, 2010, 06:25:46 AM
I find it hard to believe you couldn't find a single win32 "hello, world" NASM application that worked... You apparently didn't look hard enough. Here is a basic hello world and build instructions for Win32 using NASM and GoLINK. Try using the forum search function and possibly Google Code Search (http://www.google.com/codesearch).

Code: [Select]
BITS 32

EXTERN ExitProcess@4
EXTERN MessageBoxA@16

NULL EQU 000h
MB_OK EQU 000h
MB_ICONQUESTION EQU 020h

SECTION .data

strMessage DB "Hello, World!", 0
strTitle DB "Win32NASM", 0

SECTION .text

GLOBAL _main
_main:
Push DWORD MB_OK + MB_ICONQUESTION
Push DWORD strTitle
Push DWORD strMessage
Push DWORD NULL
Call MessageBox@16

Push DWORD 0
Call ExitProcess@4

To build it use:

Code: [Select]
nasm -f win32 -o test.obj test.asm
golink /entry _main test.obj kernel32.dll user32.dll