Could someone please tell me how to compile an assembly program.
I have the code, but I can't compile it.

Also, my "Hello, world!" program does not run when using Flat Assemble, a compiler I got off the internet.
Here is my code:

.model flat, stdcall
option casemap :none
include \masm32\include\
include \masm32\include\
include \masm32\include\
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
HelloWorld db "Hello World!", 0
invoke StdOut, addr HelloWorld
invoke ExitProcess, 0
end start

;the reason I put [] on either side of my code is to show it is code

It is meant to make a message box appear to display "Hello World!", and the program is called Hello.asm and when I compile it it says that Hello.asm is an error in the code. It doesn't make sense.

Please help me,

Recommended Answers

All 4 Replies

function stdout prints the string in to the console, so you have to "assemble" (not compile)as a console program to produce an output from the above code.
If you want to "make" a message box then you have to invoke the MessageBox funtion(In that case don't forget to include "" and "user32.lib" in your code).

You downloaded "Flat Assembler"? That is FASM, your code is MASM. It WILL NOT assemble with FASM without some modifications.

if you want to actually understand how assembly works, you shouldn't use all those pre-defined macros! there isn't one single CPU instruction in all of the code you pasted. understanding assembly means understanding the instructions and what they do.

and in the future please just use the CODE tags instead of just throwing a [ and a ] at the beginning and end.

I already tested a lot of ASM Compilers, and the one which i most liked was WinASM, but you need MASM to use it, and i think its better you use MessageBox in your hello world

PUSH 0 ;specify that its a MB_OK message
PUSH HelloWorld ;text from the message
PUSH HelloWorld ;title of the message
PUSH 0 ;handle of the message, 0 as the program itself
CALL MessageBoxA
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.