Question: 2 ) A colleague decided that the PrintInt subprogram should print a new line after the integer has been printed and has modified the PrintInt
A colleague decided that the PrintInt subprogram should print a new line after the integer has been printed and has modified the PrintInt to print a new line character as follows.
Note: PrintNewLine subprogram is described in Chapter of your textbook.
# subprogram: PrintInt
# author: Charles W Kann
# purpose: To print a string to the console
# input: $a The address of the string to print.
# $a 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 $a
li $v
syscall
# Print integer. The integer value is in $a and must
# be first moved to $a
move $a $a
li $v
syscall
# Print a new line character
jal PrintNewLine
#return
jr $ra
When the program is run, it never ends and acts like it is stuck in an infinite loop. Help this colleague figure out what is wrong with the program.
a Explain what is happening in the program that makes it an infinite loop.
b Document a solution which fixes this problem so that PrintInt prints the integer and a newline, and then returns to the point in which was called without creating and infinite loop.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
