feat: Initial commit
This commit is contained in:
87
Laboratorio8/Esercizio5.asm
Normal file
87
Laboratorio8/Esercizio5.asm
Normal file
@@ -0,0 +1,87 @@
|
||||
.data
|
||||
p: .asciiz "Il numero è palindromo"
|
||||
|
||||
.text
|
||||
.globl main
|
||||
.ent main
|
||||
main:
|
||||
addiu $sp, $sp, -4
|
||||
sw $ra, ($sp)
|
||||
|
||||
li $a0, 4
|
||||
li $a1, 3
|
||||
li $a2, 2
|
||||
li $a3, 1
|
||||
jal determinante2x2
|
||||
|
||||
lw $ra, ($sp)
|
||||
jr $ra
|
||||
.end main
|
||||
|
||||
.ent determinante3x3
|
||||
determinante3x3
|
||||
# crea frame
|
||||
sub $sp, $sp, 4
|
||||
sw $fp, ($sp)
|
||||
move $fp, $sp
|
||||
|
||||
# salva i registri
|
||||
sub $sp, $sp, 24
|
||||
sw $s0, ($sp)
|
||||
sw $s1, 4($sp)
|
||||
sw $s2, 8($sp)
|
||||
sw $s3, 12($sp)
|
||||
sw $s4, 16($sp)
|
||||
sw $ra, 20($sp)
|
||||
|
||||
move $s0, $a0
|
||||
move $s1, $a1
|
||||
move $s2, $a2
|
||||
move $s3, $a3
|
||||
|
||||
# calcolo step 1
|
||||
lw $a0, 20($fp)
|
||||
lw $a1, 16($fp)
|
||||
lw $a2, 8($fp)
|
||||
lw $a3, 4($fp)
|
||||
jal determinante2x2
|
||||
mul $s4, $v0, $s0
|
||||
|
||||
# calcolo step 2
|
||||
move $a0, $s3
|
||||
lw $a1, 16($fp)
|
||||
lw $a2, 12($fp)
|
||||
lw $a3, 4($fp)
|
||||
jal determinante2x2
|
||||
mul $t0, $v0, $s1
|
||||
addu $s4, $s4, $t0
|
||||
|
||||
# calcolo step 3
|
||||
move $a0, $s3
|
||||
lw $a1, 20($fp)
|
||||
lw $a2, 12($fp)
|
||||
lw $a3, 8($fp)
|
||||
jal determinante2x2
|
||||
mul $t0, $v0, $s2
|
||||
addu $v0, $s4, $t0
|
||||
|
||||
# ripristina i registri
|
||||
lw $s0, ($sp)
|
||||
lw $s1, 4($sp)
|
||||
lw $s2, 8($sp)
|
||||
lw $s3, 12($sp)
|
||||
lw $s4, 16($sp)
|
||||
lw $ra, 20($sp)
|
||||
lw $fp, 24($sp)
|
||||
addi $sp, $sp, 28
|
||||
|
||||
jr $ra
|
||||
.end determinante3x3
|
||||
|
||||
.ent determinante2x2
|
||||
determinante2x2:
|
||||
mul $t0, $a0, $a3
|
||||
mul $t1, $a1, $a2
|
||||
sub $v0, $t0, $t1
|
||||
jr $ra
|
||||
.end determinante2x2
|
||||
Reference in New Issue
Block a user