-
Notifications
You must be signed in to change notification settings - Fork 3
/
8.matrix_multiplication.asm
66 lines (53 loc) · 1.55 KB
/
8.matrix_multiplication.asm
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
65
66
DATA SEGMENT
MATRIX1 DW 01H, 02H, 03H
DW 04H, 05H, 06H
DW 07H, 08H, 09H
MATRIX2 DW 01H, 02H, 03H
DW 04H, 05H, 06H
DW 07H, 08H, 09H
RESULT DW 9 DUP(?)
SUM DW ?
TWO DW 2
THREE DW 3
FOUR DW 4
SIX DW 6
DATA ENDS
CODE SEGMENT
START: MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV SI,0
MOV DI,0
MOV AX,0
MOV CX,THREE ;no. of rows of Matrix1
LOOP1: MOV DI,0
PUSH CX
MOV CX,THREE ;no. of columns of Matrix2
LOOP2: MOV BX,0
MOV SUM,0
PUSH CX
MOV CX,THREE
LOOP3: MOV AX, MATRIX1[SI][BX]
PUSH BX
PUSH AX
MOV AX,BX
MUL THREE
MOV BX,AX
POP AX
MUL MATRIX2[BX][DI]
POP BX
ADD AX,SUM
MOV SUM, AX
ADD BX,2
LOOP LOOP3
MOV BX,DI
ADD DI, 2
MOV AX,SUM
MOV RESULT[SI][BX], AX
POP CX
LOOP LOOP2
ADD SI, 6
POP CX
LOOP LOOP1
CODE ENDS
END START