1 year ago
#47015
Ramish Masood
MIPS "Invalid language element:" on symbol names like 1try_msg
.data
Initial_msg: .asciiz "\nLet's play a guessing game. \nFind out the number between 1 and 10 that I generated. \nEnter 0 to give up\n\n"
Bigger_msg: .asciiz "\nMy number is bigger than that one...\n"
Smaller_msg: .asciiz "\nMy number is smaller than that one...\n"
Right_Answer_msg: .asciiz "\nYou've got it!"
Game_Over_msg: .asciiz "\nNo more tries, I've won!\n"
2tries_msg: .asciiz "You got two more tries.\n\n"
1try_msg: .asciiz "You got one more try.\n\n"
Number_msg: .asciiz "The number I chose was: "
# $s0 -> Random number generated by the computer
# $s1 -> Number chosen by the player
# $s2 -> Number of tries
.text
main:
li $v0, 42 # syscall code to generate a random number
li $a1, 10 # sets the upper bound to 10
syscall
move $t0, $a0 # moves the genrated number to register $t0
add $s0, $t0, 1 # add 1 to the number generated between 0-9
add $s2, $zero, 3 # sets $s2 to the number of tries
li $v0, 4 # syscall code to print a string
la $a0, Initial_msg
syscall
action:
li $v0, 5 # syscall code to read an integer
syscall
move $s1, $v0 # saves in $s1
beq $s1, $zero, end # verifies if the player has given up
beq $s0, $s1, got_it # checks if the player has gotten right the number
sub $s2, $s2, 1 # decreases the number of tries remaining
beq $s2, $zero game_over # the number of tries have reached zero
slt $t0, $s1, $s0
beq $t0, 1, its_bigger
its_smaller:
li $v0, 4 # syscall code to print a string
la $a0, Smaller_msg
syscall
j more_actions
its_bigger:
li $v0, 4 # syscall code to print a string
la $a0, Bigger_msg
syscall
more_actions:
beq $s2, 2, 2_tries # restam 2 tentativas
beq $s2, 1, 1_try # resta 1 tentativa
j action
2_tries:
li $v0, 4 # syscall code to print a string
la $a0, 2tries_msg
syscall
j action
1_try:
li $v0, 4 # syscall code to print a string
la $a0, 1try_msg
syscall
j action
got_it:
li $v0, 4 # syscall code to print a string
la $a0, Right_Answer_msg
syscall
j end
game_over:
li $v0, 4 # syscall code to print a string
la $a0, Game_Over_msg
syscall
li $v0, 4 # syscall code to print a string
la $a0, Number_msg
syscall
li $v0, 1 # syscall code to print a integer
la $a0, ($s0) # prints the number chosen by the computer
end:
li $v0, 10 # Ends the game
syscall
MIPS assembly language program, I need your help in MIPS assembly's program. Compiling with some errors,
2tries_msg: .asciiz "You got two more tries.\n\n" Invalid language element: 2tries_msg
Error in line 8 column 2: 1try_msg: .asciiz "You got one more try.\n\n" Invalid language element: 1try_msg
Error in line 55 column 15: beq $s2, 2, 2_tries # restam 2 tentativas Invalid language element: 2_tries
Error in line 56 column 15: beq $s2, 1, 1_try # resta 1 tentativa Invalid language element: 1_try
Error in line 60 column 2: 2_tries: Invalid language element: 2_tries
Error in line 62 column 11: la $a0, 2tries_msg Invalid language element: 2tries_msg
Error in line 66 column 2: 1_try: Invalid language element: 1_try
Error in line 68 column 11: la $a0, 1try_msg Invalid language element: 1try_msg
Assemble: operation completed with errors.
Please help me to resolve the errors.
assembly
mips
mips32
mips64
0 Answers
Your Answer