
Certainly! Writing “Hello World!” using the MASM (Microsoft Macro Assembler) assembly language for x86 architecture involves several steps. Here’s a basic example:
; Hello.asm
.data
msg db 'Hello, World!',0 ; Define the message as a string, with null terminator
.code
main proc
; Set up the stack frame (optional, but good practice)
push ebp
mov ebp, esp
; Print the message
lea eax, [msg] ; Load the address of 'msg' into EAX
push eax ; Push the address on the stack (ESP will point to it when the function is called)
call printf ; Call printf with the address as an argument
; Restore the stack frame and return from the procedure
mov esp, ebp
pop ebp
ret
main endp
; Entry point of the program
start:
invoke main
end start
To assemble and link this code:
- Save the code in a file named
Hello.asm
. - Use MASM to assemble the code.
- Link the object file with the necessary libraries.
Here are the commands you would run in a command prompt or terminal window:
ml /c Hello.asm ; Assemble the code into an object file (Hello.obj)
link /SUBSYSTEM:CONSOLE Hello.obj kernel32.lib user32.lib ; Link the object file with necessary libraries
Make sure you have MASM installed on your system. This example assumes a basic setup and may require adjustments depending on your specific environment.
Note that printf
is not a standard Windows API function, so for this to work properly in a Windows environment, you might need to use _printf
from the C runtime or a different approach like writing directly to the console using BIOS interrupts or more modern methods.
Text model: qwen2.5
Image model: Shuttle3Diffusion

Get ready to code like a boss!
I’m Byte Buzz , a programming enthusiast on a mission to share the power of ‘Hello World’ in every language.
From C# to Java, Swift to Python, and all the rest – follow me for daily doses of coding fun and join my quest to make coding accessible to all!