Music Philosophy Art Math Chess Programming and much more ...
To write, compile, and run assembler programs, you’ll need:
LINK.EXE
.Follow these steps:
; HelloWorld.asm
; A simple program to print "Hello, World!" to the console
.MODEL SMALL ; Define memory model
.STACK 100h ; Define stack size
.DATA ; Section for variables and strings
message DB 'Hello, World!$' ; Message to display, terminated with $
.CODE ; Section for code
main PROC
MOV AX, @DATA ; Load data segment address into AX
MOV DS, AX ; Move AX into DS to set data segment
LEA DX, message; Load effective address of message into DX
MOV AH, 9 ; Function to display string (INT 21h)
INT 21h ; Call DOS interrupt
MOV AH, 4Ch ; Terminate program function (INT 21h)
INT 21h ; Call DOS interrupt to exit
main ENDP
END main ; End of program
HelloWorld.asm
.Memory Model: .MODEL SMALL
uses one segment for code and one for data.
Data Section: .DATA
defines the message. The $
signals the end of the string.
Code Section:
MOV AX, @DATA / MOV DS, AX
: Sets up the data segment.LEA DX, message
: Loads the message's address into the DX
register.MOV AH, 9 / INT 21h
: Calls DOS interrupt 21h to display the string.MOV AH, 4Ch / INT 21h
: Terminates the program using DOS interrupt 21h.