.
This commit is contained in:
BIN
bac1/q2/fonctio/tp2/MIPS_Green_Sheet.pdf
Normal file
BIN
bac1/q2/fonctio/tp2/MIPS_Green_Sheet.pdf
Normal file
Binary file not shown.
BIN
bac1/q2/fonctio/tp2/fonct-ordis-tp2-spim.pdf
Normal file
BIN
bac1/q2/fonctio/tp2/fonct-ordis-tp2-spim.pdf
Normal file
Binary file not shown.
32
bac1/q2/fonctio/tp2/spim-add-int.s
Normal file
32
bac1/q2/fonctio/tp2/spim-add-int.s
Normal file
@ -0,0 +1,32 @@
|
||||
.data
|
||||
txt1: .asciiz "Entrez un premier nombre:"
|
||||
txt2: .asciiz "Entrez un second nombre:"
|
||||
|
||||
.text
|
||||
main:
|
||||
# print txt1
|
||||
la $a0, txt1
|
||||
li $v0, 4
|
||||
syscall
|
||||
|
||||
#read t0
|
||||
li $v0, 5
|
||||
syscall
|
||||
move $t0, $v0
|
||||
|
||||
# print txt2
|
||||
li $v0, 4
|
||||
la $a0, txt2
|
||||
syscall
|
||||
|
||||
#read t1
|
||||
li $v0, 5
|
||||
syscall
|
||||
move $t1, $v0
|
||||
|
||||
# a0 = t0 + t1
|
||||
add $a0, $t1, $t0
|
||||
|
||||
li $v0, 1
|
||||
syscall
|
||||
jr $ra
|
20
bac1/q2/fonctio/tp2/spim-fonction-call.s
Normal file
20
bac1/q2/fonctio/tp2/spim-fonction-call.s
Normal file
@ -0,0 +1,20 @@
|
||||
.data
|
||||
text: .asciiz "Hello I'm in my fct"
|
||||
|
||||
.text
|
||||
main:
|
||||
|
||||
# Appel Fonction
|
||||
or $t0 $zero $ra
|
||||
jal fct
|
||||
or $ra $zero $t0
|
||||
jr $ra
|
||||
|
||||
fct:
|
||||
|
||||
li $v0, 4
|
||||
la $a0, text
|
||||
syscall
|
||||
jr $ra
|
||||
|
||||
|
12
bac1/q2/fonctio/tp2/spim-loop-5-write.s
Normal file
12
bac1/q2/fonctio/tp2/spim-loop-5-write.s
Normal file
@ -0,0 +1,12 @@
|
||||
main:
|
||||
li $a0, 5
|
||||
li $a1, 0
|
||||
li $v0, 1
|
||||
j loop
|
||||
|
||||
loop:
|
||||
syscall
|
||||
addiu $a0, -1
|
||||
bne $a0, $a1, loop
|
||||
# bgtz $a0, loop
|
||||
jr $ra
|
10
bac1/q2/fonctio/tp2/spim-loop-5.s
Normal file
10
bac1/q2/fonctio/tp2/spim-loop-5.s
Normal file
@ -0,0 +1,10 @@
|
||||
main:
|
||||
li $a0, 5
|
||||
li $a1, 0
|
||||
j loop
|
||||
|
||||
loop:
|
||||
addiu $a0, -1
|
||||
bne $a0, $a1, loop
|
||||
# bgtz $a0, loop
|
||||
jr $ra
|
3
bac1/q2/fonctio/tp2/spim-loop.s
Normal file
3
bac1/q2/fonctio/tp2/spim-loop.s
Normal file
@ -0,0 +1,3 @@
|
||||
main:
|
||||
nop
|
||||
j main
|
9
bac1/q2/fonctio/tp2/spim-print-str.s
Normal file
9
bac1/q2/fonctio/tp2/spim-print-str.s
Normal file
@ -0,0 +1,9 @@
|
||||
.data
|
||||
mystr: .asciiz "The answer to live, universe and everything else is.... 42"
|
||||
|
||||
.text
|
||||
main:
|
||||
la $a0, mystr
|
||||
li $v0, 4
|
||||
syscall
|
||||
jr $ra
|
33
bac1/q2/fonctio/tp2/spim-read-int.s
Normal file
33
bac1/q2/fonctio/tp2/spim-read-int.s
Normal file
@ -0,0 +1,33 @@
|
||||
.data
|
||||
question: .asciiz "Entrez un nombre: "
|
||||
gr: .asciiz "Trop Grand!\n"
|
||||
pe: .asciiz "Valeur acceptee\n"
|
||||
|
||||
.text
|
||||
main:
|
||||
la $a0, question
|
||||
li $v0, 4
|
||||
syscall
|
||||
|
||||
li $v0, 5
|
||||
syscall
|
||||
|
||||
bgt $v0, 10, grand
|
||||
bgt $v0, 0, petit
|
||||
jr $ra
|
||||
|
||||
grand:
|
||||
la $a0, gr
|
||||
li $v0, 4
|
||||
syscall
|
||||
j main
|
||||
|
||||
petit:
|
||||
la $a0, pe
|
||||
li $v0, 4
|
||||
syscall
|
||||
|
||||
lr $a0,
|
||||
li $v0, 4
|
||||
syscall
|
||||
j main
|
27
bac1/q2/fonctio/tp2/spim-to-binary.s
Normal file
27
bac1/q2/fonctio/tp2/spim-to-binary.s
Normal file
@ -0,0 +1,27 @@
|
||||
.data
|
||||
ask: .ascii "Entrez un nombre:"
|
||||
|
||||
.text
|
||||
main:
|
||||
|
||||
# Print(ask)
|
||||
li $v0 4
|
||||
la $a0 ask
|
||||
syscall
|
||||
|
||||
# read()
|
||||
li $v0 5
|
||||
syscall
|
||||
|
||||
li $t0 2 #base
|
||||
|
||||
divi:
|
||||
|
||||
div $v0, $t0
|
||||
li $v0, 1
|
||||
mfhi $a0
|
||||
syscall
|
||||
mflo $v0
|
||||
bne $v0, 0, divi
|
||||
|
||||
jr $ra
|
27
bac1/q2/fonctio/tp2/spim-to-hex.s
Normal file
27
bac1/q2/fonctio/tp2/spim-to-hex.s
Normal file
@ -0,0 +1,27 @@
|
||||
.data
|
||||
hex: .asciiz "0123456789ABCDEF"
|
||||
q1: .asciiz "Entrez un nombre"
|
||||
.text
|
||||
main:
|
||||
li $v0, 4
|
||||
la $a0, q1
|
||||
syscall
|
||||
|
||||
li $v0, 5
|
||||
syscall
|
||||
|
||||
li $t0 16 #base
|
||||
|
||||
divi:
|
||||
div $v0, $t0
|
||||
mfhi $t2
|
||||
la $t9, hex
|
||||
addu $t9, $t9, $t2
|
||||
lb $a0 0($t9)
|
||||
li $v0, 11
|
||||
syscall
|
||||
|
||||
mflo $v0
|
||||
bne $v0, 0, divi
|
||||
|
||||
jr $ra
|
63
bac1/q2/fonctio/tp2/switch-table.s
Normal file
63
bac1/q2/fonctio/tp2/switch-table.s
Normal file
@ -0,0 +1,63 @@
|
||||
.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:
|
||||
# ask a number
|
||||
li $v0, 4
|
||||
la $a0, q1
|
||||
syscall
|
||||
|
||||
# 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
|
||||
|
||||
end_case:
|
||||
jr $ra
|
Reference in New Issue
Block a user