Hi, I am multiplying two matricies in assembly. It is a 2 x 2, and as you can see they are defined down below in the code. I am also defining storate for 4 words so tht I can save the resulting matrix.
1. I declare offset fo each matrix
2. I also declare columns and rows so I can keep control of when to end everyhting.
3. The program goes through first row in matrix by using diplacement.
4. For the second matrix, the one I am multiplying it by, I am incrementing offset by column number because I want to move down a column.
5. D7 which is constant for repeat, is used becasue I need to repeat multiplication for same rown in 1st matrix.
6. The program runs fine for first loop, and once BNE L1, and it goes into the second loop, it gives me this error:

Here is an image of the problem:

http://s1107.photobucket.com/user/Nazariy1995/media/Problem.png.html

Here is my code:

``````*-----------------------------------------------------------
* Title      :
* Written by :
* Date       :
* Description:
*-----------------------------------------------------------
r   EQU     2   ;number of rows
c   EQU     2   ;number of columns
ORG    \$1000
START:  MOVEA.L     #A,A0
MOVEA.L     #B,A1
MOVEA.L     #D,A2

MOVE.W      #r,D3   ;used for rows
CLR.W       D0  ;offset for A
CLR.W       D1  ;offset for B
CLR.W       D2  ;offset for D
CLR.W       D5  ;calculating the sum
CLR.W       D6  ;calculaing the multiplication
CLR.W       D7  ;used for number of repeats
L2      MOVE.W      #c,D4   ;used for columns mainly for first matrix
L1      CLR.W       D5
MOVE.W      (A0,D0.W),D5
MULU        (A1,D1.W),D5
ADD.W       #c,D1   ;we are moving down a column and thus are adding column to the offset in B
SUB.W       #1,D4
BNE         L1
MOVE.W      D6,(A2,D2.W)
ADD.W       #1,D2   ;increment counter for C
CMP.W       #c,D7   ;number of repeats  should be equal to column number
BNE         RE
CLR.W       D7      ;clear repeats because we are moving on to a new row
CLR.W       D1      ;set offset for B to 0
SUB.W       #1,D3   ;find out through how many rows we went through
BNE         L2
STOP        #\$2700

RE      SUB.W      #c,D0    ;got at the beginning of a row in A
MOVE.W      D7,D1
CLR.W       D6
BSR        L2

* Put program code here

SIMHALT             ; halt simulator

* Put variables and constants here
A   DC.W    1,2,0,1
B   DC.W    1,0,2,1
D   DS.W    4

END    START        ; last line of source
``````