Add TD5 exercice 1
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 22 Jun 2017 09:24:47 +0000 (11:24 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 22 Jun 2017 09:24:47 +0000 (11:24 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
TD5/mips1.asm [new file with mode: 0644]

diff --git a/TD5/mips1.asm b/TD5/mips1.asm
new file mode 100644 (file)
index 0000000..bf65f24
--- /dev/null
@@ -0,0 +1,51 @@
+.text
+main:
+       li   $a0, 5
+       li   $a1, 10
+       addi $sp, $sp, -12
+       
+       sw   $a0, 4($sp)
+       sw   $a1, 0($sp)
+       jal  opMult
+       
+       lw   $v0, 0($sp)
+       addi $sp, $sp, 4
+       
+       move $a0, $v0
+       li   $v0, 1
+       syscall
+       li   $v0, 10
+       syscall
+       
+opMult:
+       addi $sp, $sp, -40
+       sw   $fp, 36($sp)
+       sw   $ra, 32($sp)
+       sw   $s0, 28($sp)
+       sw   $s1, 24($sp)
+       sw   $s2, 20($sp)
+       sw   $s3, 16($sp)
+       sw   $s4, 12($sp)
+       sw   $s5, 8($sp)
+       sw   $s6, 4($sp)
+       sw   $s7, 0($sp)
+       addi $fp, $sp, 36
+       
+       lw   $t1, 8($fp)
+       lw   $t2, 4($fp)
+       mul  $t1, $t1, $t2
+       sw   $t1, 12($fp)
+       
+       lw   $s7, 0($sp)
+       lw   $s6, 4($sp)
+       lw   $s5, 8($sp)
+       lw   $s4, 12($sp)
+       lw   $s3, 16($sp)
+       lw   $s2, 20($sp)
+       lw   $s1, 24($sp)
+       lw   $s0, 28($sp)       
+       lw   $ra, 32($sp)
+       lw   $fp, 36($sp)
+       addi $sp, $sp, 48
+       jr   $ra
+