A colleague felt that the PrintInt subprogram should print a new line after the number, so he updated the PrintInt to output the following new line character. # subprogram: PrintInt # author: Charles W. Kann # purpose: To print a string to the console # input: $a0 - The address of the string to print. # $a1 - The value of the int to print # returns: None # side effects: The String is printed followed by the integer value. .text PrintInt: # Print string. The string address is already in $a0 li $v0, 4 syscall # Print integer. The integer value is in $a1, and must # be first moved to $a0. move $a0, $a1 li $v0, 1 syscall # Print a new line character jal PrintNewLine #return jr $raWhen the programme is executed, it never stops and appears to be stuck in an unending loop. Assist this colleague in determining what is wrong with the programme. a. Explain what is going on in the programme. b. Create a technique that demonstrates that this programme is actually in an infinite loop. c. Come up with a solution to this dilemma.
A colleague felt that the PrintInt subprogram should print a new line after the number, so he updated the PrintInt to output the following new line character.
# subprogram: PrintInt
# author: Charles W. Kann
# purpose: To print a string to the console
# input: $a0 - The address of the string to print.
# $a1 - The value of the int to print
# returns: None
# side effects: The String is printed followed by the integer
value.
.text
PrintInt:
# Print string. The string address is already in $a0
li $v0, 4
syscall
# Print integer. The integer value is in $a1, and must
# be first moved to $a0.
move $a0, $a1
li $v0, 1
syscall
# Print a new line character
jal PrintNewLine
#return
jr $raWhen the programme is executed, it never stops and appears to be stuck in an unending loop. Assist this colleague in determining what is wrong with the programme.
a. Explain what is going on in the programme. b. Create a technique that demonstrates that this programme is actually in an infinite loop.
c. Come up with a solution to this dilemma.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images