1
0

feat: Initial commit

This commit is contained in:
2024-03-22 13:53:19 +01:00
parent 44aa2938a2
commit 2a54d9dbc2
34 changed files with 1475 additions and 0 deletions

87
Temi esame/unamatrice.asm Normal file
View File

@@ -0,0 +1,87 @@
N =, 3
M =, 4
.data
matriceA:
.word 0xAB317811, 0xCD514229, 0xEF832040, 0xA1346269
.word 0xB2178309, 0xC3524578, 0x65702887, 0x59227465
.word 0x14930352, 0x24157817, 0x39088169, 0x63245986
matriceB:
.word 0x39916800, 0x47900160, 0x62270208, 0x87178291
.word 0xA7674368, 0xB2092278, 0xC3556874, 0xD6402373
.word 0xE1216451, 0x24329020, 0x51090942, 0x11240007
matriceC:
.space N * M * 4
.text
.globl main
.ent main
main:
subu $sp, $sp, 4
sw $ra, ($sp)
la $a0, matriceA
la $a1, matriceB
la $a2, matriceC
li $a3, N
li $t0, M
subu $sp, $sp, 4
sw $t0, ($sp)
jal MediaMatrice
addiu $sp, $sp, 4
lw $ra, ($sp)
addiu $sp, $sp, 4
jr $ra
.end main
.ent MediaMatrice
MediaMatrice:
mult $a3, $t0
mflo $a3
li $t1, 0
loop_colonna:
li $t2, 0
loop_riga:
addu $t3, $t1, $t2
sll $t3, $t3, 2
addu $t3, $t3, $a0
lw $t3, ($t3)
addu $t4, $t1, $t2
sll $t4, $t4, 2
addu $t4, $t4, $a1
lw $t4, ($t4)
slt $t5, $t3, $0
slt $t6, $t3, $0
xor $t5, $t5, $t6
bne $t5, $0, opposto
addu $t4, $t3, $t4
srl $t4, $t4, 1
li $t5, 0x80000000
and $t3, $t3, $t5
or $t4, $t4, $t3
j salva_media
opposto:
add $t4, $t3, $t4
sra $t4, $t4, 1
salva_media:
addu $t3, $t1, $t2
sll $t3, $t3, 2
addu $t3, $t3, $a2
sw $t4, ($t3)
addiu $t2, $t2, 1
bne $t2, $t0, loop_riga
addu $t1, $t1, $t0
bne $t1, $a3, loop_colonna
jr $ra
.end MediaMatrice