# 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 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 b. Come up with a mechanism which shows that this program is indeed in an infinite loop. c. Come up with a solution which fixes this problem.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section: Chapter Questions
Problem 9PP
icon
Related questions
Question

# 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 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
b. Come up with a mechanism which shows that this program is indeed in an infinite
loop.
c. Come up with a solution which fixes this problem. 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Types of Loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage