blob: 13918d27a00f65337277e38e87527326146f710b (
plain)
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
67
68
69
70
|
;;;;;;;;
;;; performs a matrix multiply on the 4x4 square matrices
;;; m1 and m2,
;;; the result of which is placed into
;;; r,
;;; in this case, the result is the identity
;;; does not use designated vector instructions
.data
m1 01 00 -1 00 00 01 00 -1 00 00 01 00 00 00 00 01
m2 01 00 01 00 00 01 00 01 00 00 01 00 00 00 00 01
r 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
.text
addi $8 $0 0x4 ; dimensions
addi $9 $0 0x0 ; tracks the rows
jrl ROWCOND
ROW:
addi $10 $0 0x0 ; tracks the columns
jrl COLCOND
COL:
addi $11 $0 0x0 ; tracks the element being added
addi $12 $0 0x0 ; the accumulated result to place into $9,$10
mul $7 $9 $8 ; setup the index into m1
addi $5 $7 m1
addi $6 $0 m2 ; setup the index into m2
add $6 $6 $10
addi $15 $5 0 ; setup a base address into both
addi $7 $6 0
jrl ELECOND
ELE:
add $5 $15 $11 ; increment m1
mul $13 $11 $8 ; increment m2
add $6 $7 $13
load $13 0($5) ; retrieve and accumulate
load $14 0($6)
mul $13 $14 $13
add $12 $12 $13
addi $11 $11 0x1
ELECOND:
cmp $8 $11
bgt ELE
mul $7 $9 $8
add $7 $7 $10
addi $7 $7 r
store $12 0($7)
addi $10 $10 0x1
COLCOND:
cmp $8 $10
bgt COL
addi $9 $9 0x1
ROWCOND:
cmp $8 $9
bgt ROW
nop
nop
nop
nop
nop
|