A) Describe what is happening in the programme; B) devise a method that would demonstrate that the programme is, in fact, in an infinite loop. c. Develop a solution that resolves this issue.
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 $ra
When 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) Describe what is happening in the programme; B) devise a method that would demonstrate that the programme is, in fact, in an infinite loop.
c. Develop a solution that resolves this issue.
Step by step
Solved in 3 steps