Question: Task: The following algorithm has been implemented as an LMC program; however, the LMC program does not behave as expected and the developer has not
Task: The following algorithm has been implemented as an LMC program; however, the LMC program does not behave as expected and the developer has not indented or commented on the code making readability difficult.
Algorithm
CountItemsGreaterThanX
n userspecified number of items
x userspecified value for X
c count of items greater than X
while n is greater than
m userspecified item
if m x
c c
n n
Display the count, c
LMC program
IN
STO INPUTCOUNT
IN STO X
LOOPSTART: LDA LOOPCOUNT
ADD ONE
STO LOOPCOUNT
LDA INPUTCOUNT
SUB LOOPCOUNT
BR CONTINUELOOP
BR LOOPEND
CONTINUELOOP: IN
SUB X
BRP COUNTINC
BR LOOPSTART
COUNTINC: LDA NUMITEMSGREATER
ADD ONE
STO NUMITEMSGREATER
BR LOOPSTART
LOPEND: LDA NUMITEMSGREATER
OUT
HLT
INPUTCOUNT: DAT
LOOPCOUNT: DAT
NUMITEMSGREATER: DAT
ONE: DAT
X: DAT
To understand the LMC program, identify the errors and correct the given program so that the implementation matches the algorithm.
Describe the changes that you make and provide reasons for the changes in the provided template.
Write a test suite to be used to verify that the updated program is correct.
Use your test suite to demonstrate that the program is correct.
Provide indentation and comments in the LMC program where necessary.
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
