This commit is contained in:
Debucquoy Anthony 2023-05-05 16:04:44 +02:00
parent a526edbd8d
commit 690720e54d
Signed by: tonitch
GPG Key ID: A78D6421F083D42E
2 changed files with 63 additions and 2 deletions

View File

@ -0,0 +1,27 @@
.data
hex: .asciiz "0123456789ABCDEF"
q1: .asciiz "Entrez un nombre"
.text
main:
li $v0, 4
la $a0, q1
la $t9, hex
syscall
li $v0, 5
syscall
li $t0 16 #base
divi:
div $v0, $t0
mfhi $t2
addu $t9, $t9, $t2
lb $a0 0($t9)
li $v0, 11
syscall
mflo $v0
bne $v0, 0, divi
jr $ra

View File

@ -1,27 +1,61 @@
.data
tab: .word case5, case6, case7, case8
q1: .asciiz "Entrez un nombre entre 5 et 8:"
r5: .asciiz "case 5"
r6: .asciiz "case 6"
r7: .asciiz "case 7"
r8: .asciiz "case 8"
.text
main:
li $v0, 5
# ask a number
li $v0, 4
la $a0, q1
syscall
li $v0, 4
# read the number
li $v0, 5
syscall
li $t5, 5
li $t4, 4
sub $t1, $v0, $t5
mult $t1, $t4
mflo $t2
# Load addr : tab
la $t1, tab
addu $t1, $t2, $t1
lw $t0,0($t1)
jr $t0
case5:
li $v0, 4
la $a0, r5
syscall
j end_case
case6:
li $v0, 4
la $a0, r6
syscall
j end_case
case7:
li $v0, 4
la $a0, r7
syscall
j end_case
case8:
li $v0, 4
la $a0, r8
syscall
j end_case