repositories
/
TD_IML.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Code cleanups.
[TD_IML.git]
/
project
/
mips1.asm
diff --git
a/project/mips1.asm
b/project/mips1.asm
index 2cba67ed05e73922db4a4df3b1991f0150f49f03..9c8695193024b98f4f75692dd5094a7966a595ba 100644
(file)
--- a/
project/mips1.asm
+++ b/
project/mips1.asm
@@
-2,10
+2,10
@@
welcome: .asciiz "Bienvenue dans le jeu de Mastermind.\nUne sequence de quatre chiffres de 1 à 8 a ete générée.\nA vous de la deviner !"
play: .asciiz "Commencer à jouer:"
welcome: .asciiz "Bienvenue dans le jeu de Mastermind.\nUne sequence de quatre chiffres de 1 à 8 a ete générée.\nA vous de la deviner !"
play: .asciiz "Commencer à jouer:"
-lost_msg: .asciiz "Vous avez perdu !"
+lost_msg: .asciiz "Vous avez perdu !"
win_msg: .asciiz "Vous avez gagné !"
win_msg: .asciiz "Vous avez gagné !"
-temp_msg: .asciiz " bien placé"
-exclamation_point: .asciiz "! "
+temp_msg: .asciiz " bien placé"
+exclamation_point: .asciiz "! "
interrogation_point: .asciiz "? "
newline: .asciiz "\n"
interrogation_point: .asciiz "? "
newline: .asciiz "\n"
@@
-38,38
+38,38
@@
display_welcome:
la $a0, newline
li $v0, 4
syscall
la $a0, newline
li $v0, 4
syscall
-
+
generate_sequence:
la $t0, guess_value
generate_sequence:
la $t0, guess_value
-
+
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
-
+
sb $a0, 0($t0)
sb $a0, 0($t0)
-
+
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
-
+
sb $a0, 1($t0)
sb $a0, 1($t0)
-
+
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
-
+
sb $a0, 2($t0)
sb $a0, 2($t0)
-
+
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
li $a1, 8
li $v0, 42
syscall
addi $a0, $a0, 1 # Put the integer into the [1-8] range
-
+
sb $a0, 3($t0)
sb $a0, 3($t0)
-
+
generate_sequence_loop_end:
la $s0, ($zero) # Initialize loop counter to zero
generate_sequence_loop_end:
la $s0, ($zero) # Initialize loop counter to zero
@@
-81,56
+81,56
@@
input:
la $a0, newline
li $v0, 4
syscall
la $a0, newline
li $v0, 4
syscall
-
+
la $a0, ($s0)
li $v0, 1
syscall
la $a0, interrogation_point
li $v0, 4
syscall
la $a0, ($s0)
li $v0, 1
syscall
la $a0, interrogation_point
li $v0, 4
syscall
-
+
la $a0, input_value # Store the answer
li $a1, 5
li $v0, 8 # Load syscall read_string
la $a0, input_value # Store the answer
li $a1, 5
li $v0, 8 # Load syscall read_string
- syscall
# Make the syscall
+ syscall
# Make the syscall
-# check that each input values are in the right range
+# check that each input values are in the right range
check_input:
la $t7, input_value
check_input:
la $t7, input_value
-
+
lb $t5, 0($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
bgez $t5, input
lb $t5, 0($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
bgez $t5, input
-
+
lb $t5, 1($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
bgez $t5, input
lb $t5, 1($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
bgez $t5, input
-
+
lb $t5, 2($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
lb $t5, 2($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
- bgez $t5, input
-
+ bgez $t5, input
+
lb $t5, 3($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
lb $t5, 3($t7)
andi $t5, $t5, 0x0F # ASCII code to integer
beq $t5, $zero, input
addi $t5, $t5, -9
- bgez $t5, input
-
+ bgez $t5, input
+
la $s2, ($zero) # Same counter
la $s2, ($zero) # Same counter
- la $s3 ($zero)
+ la $s3 ($zero)
compare_input:
la $t7, input_value
la $t6, guess_value
la $t5, O
la $t4, X
compare_input:
la $t7, input_value
la $t6, guess_value
la $t5, O
la $t4, X
- la $t3, tiret
-
+ la $t3, tiret
+
lb $t0, 0($t7)
andi $t0, $t0, 0x0F # ASCII code to integer
lb $t1, 0($t6)
lb $t0, 0($t7)
andi $t0, $t0, 0x0F # ASCII code to integer
lb $t1, 0($t6)
@@
-139,8
+139,8
@@
compare_input:
same1:
sb $0, 0($t7)
sb $t5, 0($s1)
same1:
sb $0, 0($t7)
sb $t5, 0($s1)
- addi $s2, $s2, 1
-different1:
+ addi $s2, $s2, 1
+different1:
lb $t0, 1($t7)
andi $t0, $t0, 0x0F # ASCII code to integer
lb $t1, 1($t6)
lb $t0, 1($t7)
andi $t0, $t0, 0x0F # ASCII code to integer
lb $t1, 1($t6)
@@
-160,21
+160,21
@@
same3:
sb $zero, 2($t7)
sb $t5, 2($s1)
addi $s2, $s2, 1
sb $zero, 2($t7)
sb $t5, 2($s1)
addi $s2, $s2, 1
-different3:
+different3:
lb $t0, 3($t7)
andi $t0, $t0, 0x0F # ASCII code to integer
lb $t1, 3($t6)
beq $t0, $t1, same4
lb $t0, 3($t7)
andi $t0, $t0, 0x0F # ASCII code to integer
lb $t1, 3($t6)
beq $t0, $t1, same4
- j different4
-same4:
+ j different4
+same4:
sb $zero, 3($t7)
sb $t5, 3($s1)
addi $s2, $s2, 1
different4:
sb $zero, 3($t7)
sb $t5, 3($s1)
addi $s2, $s2, 1
different4:
- beq $s2, 4, won
-
-
-print_comp_result:
+ beq $s2, 4, won
+
+
+print_comp_result:
la $a0, newline
li $v0, 4
syscall
la $a0, newline
li $v0, 4
syscall
@@
-190,30
+190,30
@@
print_comp_result:
la $a0, temp_msg
li $v0, 4
syscall
la $a0, temp_msg
li $v0, 4
syscall
-
+
addi $s0, $s0, 1
addi $s0, $s0, 1
- j loop
-
+ j loop
+
won:
la $a0, newline
li $v0, 4
syscall
la $a0, win_msg
li $v0, 4
won:
la $a0, newline
li $v0, 4
syscall
la $a0, win_msg
li $v0, 4
- syscall
-
+ syscall
+
j exit
j exit
-
+
lost:
la $a0, newline
li $v0, 4
lost:
la $a0, newline
li $v0, 4
- syscall
+ syscall
la $a0, lost_msg
li $v0, 4
la $a0, lost_msg
li $v0, 4
- syscall
-
+ syscall
+
j exit
j exit
-
+
exit:
li $v0, 10
syscall
exit:
li $v0, 10
syscall