-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathhello_world_string.asm
More file actions
50 lines (42 loc) · 2.02 KB
/
hello_world_string.asm
File metadata and controls
50 lines (42 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
; =============================================================================
; TITLE: Hello World (Segmented EXE style)
; DESCRIPTION: Standard multi-segment application structure displaying
; a string using DOS services.
; AUTHOR: Amey Thakur (https://github.com/Amey-Thakur)
; REPOSITORY: https://github.com/Amey-Thakur/8086-ASSEMBLY-LANGUAGE-PROGRAMS
; LICENSE: MIT License
; =============================================================================
; -----------------------------------------------------------------------------
; DATA SEGMENT
; -----------------------------------------------------------------------------
DATA SEGMENT
MSG DB "Hello, World!$"
DATA ENDS
; -----------------------------------------------------------------------------
; CODE SEGMENT
; -----------------------------------------------------------------------------
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
; Standard Initialization for Segmented EXE
MOV AX, DATA ; Load segment address of DATA
MOV DS, AX ; Point DS to it
; Prepare string output
LEA DX, MSG ; Load offset of the string
MOV AH, 09H ; DOS function: display string
INT 21H ; Call DOS system services
EXIT:
; Terminate process (Standard DOS Exit)
MOV AX, 4C00H ; AH=4Ch (Exit), AL=00h (Return Code)
INT 21H ; Return control to MS-DOS
CODE ENDS
END START
; =============================================================================
; TECHNICAL NOTES
; =============================================================================
; 1. ARCHITECTURE:
; - EXE files can have multiple segments (Code, Data, Stack).
; - 'ASSUME' tells the assembler which segment register points where.
; - 'MOV DS, AX' is required because you cannot move immediate values
; directly into segment registers.
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =