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.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter7: User-defined Simple Data Types, Namespaces, And The String Type
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Algebraic Expressions
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage