-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathprocedure_multiplication.asm
More file actions
45 lines (38 loc) · 1.97 KB
/
procedure_multiplication.asm
File metadata and controls
45 lines (38 loc) · 1.97 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
; =============================================================================
; TITLE: Reusable Multiplication Procedure
; DESCRIPTION: Demonstrate multiple calls to a single multiplication procedure
; that uses registers for parameter passing.
; AUTHOR: Amey Thakur (https://github.com/Amey-Thakur)
; REPOSITORY: https://github.com/Amey-Thakur/8086-ASSEMBLY-LANGUAGE-PROGRAMS
; LICENSE: MIT License
; =============================================================================
ORG 100H ; Start of COM program
; -----------------------------------------------------------------------------
; MAIN CODE SECTION
; -----------------------------------------------------------------------------
START:
MOV AL, 1 ; Initial value
MOV BL, 2 ; Multiplier
; Repeatedly double the value in AL by calling PROC_MUL
CALL PROC_MUL ; AL = 1 * 2 = 2
CALL PROC_MUL ; AL = 2 * 2 = 4
CALL PROC_MUL ; AL = 4 * 2 = 8
CALL PROC_MUL ; AL = 8 * 2 = 16
RET ; Return to OS
; -----------------------------------------------------------------------------
; PROCEDURE: PROC_MUL
; Description: Multiplies AL by BL. Result stored in AX.
; -----------------------------------------------------------------------------
PROC_MUL PROC
MUL BL ; AX = AL * BL
RET ; Return to caller
PROC_MUL ENDP
END
; =============================================================================
; TECHNICAL NOTES
; =============================================================================
; 1. CODE REUSE:
; - Defining logic once (e.g. math operations) and calling it repeatedly
; reduces code size (drastically in larger programs).
; - 'MUL source' performs unsigned multiplication.
; = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =