-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathhello_world_procedure_advanced.asm
More file actions
64 lines (50 loc) · 2.65 KB
/
hello_world_procedure_advanced.asm
File metadata and controls
64 lines (50 loc) · 2.65 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
; =============================================================================
; TITLE: Hello World Procedure (Advanced)
; DESCRIPTION: Refined version of the string-printing procedure demonstration,
; focusing on the use of SI as a source pointer and null-termination.
; AUTHOR: Amey Thakur (https://github.com/Amey-Thakur)
; REPOSITORY: https://github.com/Amey-Thakur/8086-ASSEMBLY-LANGUAGE-PROGRAMS
; LICENSE: MIT License
; =============================================================================
ORG 100H ; COM file entry point
; -----------------------------------------------------------------------------
; MAIN CODE SECTION
; -----------------------------------------------------------------------------
START:
; Load the memory address of the string into the Source Index register
LEA SI, MSG
; Execute the print routine
CALL PRINT_STRING
RET ; Standard COM exit
; -----------------------------------------------------------------------------
; PROCEDURE: PRINT_STRING
; Description: Iteratively prints characters from the address in SI until
; a binary zero (null) is encountered.
; -----------------------------------------------------------------------------
PRINT_STRING PROC
CHARACTER_LOOP:
; Check if the byte at the current SI address is 0
CMP BYTE PTR [SI], 0
JE FINISHED ; Exit loop if null terminator found
MOV AL, [SI] ; Fetch ASCII char into AL
; Using BIOS Video TTY Service
MOV AH, 0EH
INT 10H
INC SI ; Point to next memory location
JMP CHARACTER_LOOP ; Continue to next character
FINISHED:
RET ; Pop return address and jump back
PRINT_STRING ENDP
; -----------------------------------------------------------------------------
; DATA SECTION
; -----------------------------------------------------------------------------
MSG DB 'Hello World!', 0 ; The string to be printed
END
; =============================================================================
; TECHNICAL NOTES
; =============================================================================
; 1. POINTERS:
; - 'BYTE PTR' is used to tell the assembler we are comparing a single byte.
; - This pattern is common in C-style string processing.
; - SI (Source Index) is the standard register for scanning memory data.
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =