-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathbasic_procedure.asm
More file actions
47 lines (40 loc) · 2.07 KB
/
basic_procedure.asm
File metadata and controls
47 lines (40 loc) · 2.07 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
; =============================================================================
; TITLE: Basic Procedure Execution
; DESCRIPTION: Demonstrate the use of subroutines to avoid code duplication
; for repetitive tasks like numeric scaling.
; AUTHOR: Amey Thakur (https://github.com/Amey-Thakur)
; REPOSITORY: https://github.com/Amey-Thakur/8086-ASSEMBLY-LANGUAGE-PROGRAMS
; LICENSE: MIT License
; =============================================================================
ORG 100H ; Standard COM entry point
; -----------------------------------------------------------------------------
; MAIN EXECUTION FLOW
; -----------------------------------------------------------------------------
START:
MOV AL, 01H ; Initial value
MOV BL, 02H ; Scaling factor
; Repeatedly double the value in AL by invoking the M2 procedure
CALL M2 ; AL = 2
CALL M2 ; AL = 4
CALL M2 ; AL = 8
CALL M2 ; AL = 16
; Return back to the shell
RET
; -----------------------------------------------------------------------------
; SUBROUTINE: M2
; Description: Multiplies AL by BL. Result returns in AX.
; -----------------------------------------------------------------------------
M2 PROC
MUL BL ; Multiply accumulator by BL
RET ; Jump back to the caller (POP IP)
M2 ENDP
END
; =============================================================================
; TECHNICAL NOTES
; =============================================================================
; 1. PROCEDURES:
; - Procedures (Procs) encapsulate reusable logic.
; - The 'CALL' instruction pushes the IP (Instruction Pointer) onto the stack.
; - The 'RET' instruction pops that address back into the IP to resume flow.
; - This reduces the binary size compared to inline macro expansion.
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =