forked from kingspp/8086-MicroProcessor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatrix-Addition.asm
More file actions
45 lines (41 loc) · 1.33 KB
/
Matrix-Addition.asm
File metadata and controls
45 lines (41 loc) · 1.33 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
;############################################################################
;# 8086 Program to add two 4x4 Matrices and present result in decimal form #
;# Author: kingspp #
;############################################################################
; Declaration Part
.MODEL SMALL
.DATA
M DB 01H,02H,03H,04H ; Matrix M is a 4x4 Matrix
N DB 05H,06H,07H,08H ; Matrix N is a 4x4 Matrix
CNT DB 04H
RES DB ?
.CODE
START: MOV AX,@DATA
MOV DS,AX
MOV CL,CNT ; CL is loaded with CNT for looping
LEA SI ,M ; SI is loaded with address of Matrix M
LEA DI,N ; DI is loaded with address of Matrix N
;Matrix Adiition Part
L1:MOV AL,[SI]
MOV BL,[DI]
ADD AL,BL ; Add the Matrices
DAA ; Adjust the Result to show Decimal Value
PUSH AX ; Push the result for storing Operations, Since both SI and DI is used
INC SI
INC DI
LOOP L1
CALL STORE
;Store Part
STORE PROC
POP AX ; POP the Unwanted values first
LEA SI,RES
ADD SI,04H
MOV CL,04H
L2:POP AX ; POP the last stored result. Here SI is added 4 and then decremented since PUSH-POP follows LIFO Principle
MOV [SI],AL
DEC SI
LOOP L2
INT 3H ; Since Storing is completed terminate the program
RET
STORE ENDP
END START