I am trying to multiply two matrices of dimension 3x3 and want to store the result in the new 2d array. I know very well the algorithm in C++ that how to do, but the main problem for me is with iterating the three loops and setting the pointers in case of 8086
In c++ , below will be the simple code
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
for(int k=0;k<3;k++)
mat3[i][j]+=(mat1[i][k]*mat2[k][j]);
}
}
But coding the above code in MASM seems very difficult, please help me that how to approach the coding part in MASM (8086) Below is the code that I have written and below is the sample array, actually, I know the below code is incomplete but I am not able to think how to go further with so limited number of register contents(maybe there will be a good approach but my knowledge is limited about it)
ASSUME CS:CODE , DS:DATA
DATA SEGMENT
ARR1 DW 01H,02H,03H
DW 05H,06H,07H
DW 08H,09H,02H
ARR2 DW 03H,04H,05H
DW 06H,07H,08H
DW 10H,11H,12H
ARR RES DW 00H,00H,00H
DW 00H,00H,00H
DW 00H,00H,00H
DATA ENDS
CODE SEGMENT
START:
MOV AX,DATA
MOV DS,AX
MOV SI,OFFSET ARR1
MOV DX,OFFSET ARR2
MOV AX,OFFSET RES3
MOV CL,00H
MOV CH,03H
MOV BL,03H
MOV BH,00H
LOOP1:
LOOP2:
LOOP3:
ADD CL,03H
SUB CL,09H
JZ END
JMP LOOP1
CODE ENDS
END START
;DOUBTS
;HOW TO USE INTIALIZE THE STARTING ADDRESS OF THE 2D ARRAY WITH SO MYCH
;LIMITED REGISTERS