summaryrefslogtreecommitdiff
path: root/input/identity.asm
diff options
context:
space:
mode:
authorSiddarth Suresh <155843085+SiddarthSuresh98@users.noreply.github.com>2025-04-12 13:06:51 -0400
committerGitHub <noreply@github.com>2025-04-12 13:06:51 -0400
commitfc20e7e7276b712f1e8db773b9215f900e877169 (patch)
treecaecdd1499d2e391cd5bd2dcde3aebfade002a09 /input/identity.asm
parent5dbf0b63988b42c112ca0087cbbbb090566df5c1 (diff)
parent639098b1ea82be82bd18a4af415458fcbaf5e20b (diff)
Merge pull request #8 from bdunahu/bdunahu
Add write raw bytes stage
Diffstat (limited to 'input/identity.asm')
-rw-r--r--input/identity.asm59
1 files changed, 59 insertions, 0 deletions
diff --git a/input/identity.asm b/input/identity.asm
new file mode 100644
index 0000000..e6d9260
--- /dev/null
+++ b/input/identity.asm
@@ -0,0 +1,59 @@
+;;;;;;;;
+;;; 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
+ addi $10 $0 0x0 ; tracks the columns
+ jrl ROWCOND
+
+ROW:
+ 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
+
+ jrl ELECOND
+ELE:
+ add $5 $5 $11 ; increment m1
+
+ mul $13 $11 $8 ; increment m2
+ add $6 $6 $13
+
+ load $13 0($5) ; retrieve and accumulate
+ load $14 0($6)
+ add $12 $14 $13
+
+ addi $11 $11 0x1
+ELECOND:
+ cmp $8 $11
+ bgt ELE
+ addi $10 $10 0x1
+COLCOND:
+ cmp $8 $10
+ bgt COL
+
+ add $7 $7 $10 ; setup the index into r
+ addi $7 $7 r
+
+ store $12 0($7)
+
+ addi $9 $9 0x1
+ROWCOND:
+ cmp $8 $9
+ bgt ROW