From: Jérôme Benoit Date: Thu, 22 Jun 2017 09:24:47 +0000 (+0200) Subject: Add TD5 exercice 1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c4564fcfe6bf724c904124e78e00a05d829a0b44;p=TD_IML.git Add TD5 exercice 1 Signed-off-by: Jérôme Benoit --- diff --git a/TD5/mips1.asm b/TD5/mips1.asm new file mode 100644 index 0000000..bf65f24 --- /dev/null +++ b/TD5/mips1.asm @@ -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 +