Question: 3 . Below is a Little Man program that solves exercise 6 . 9 , p . 1 6 4 , from textbook. The program
Below is a Little Man program that solves exercise p from textbook. The program is very similar to the LMC program which you will find in the lecture notes on Chapter posted on Blackboard and discussed in Panopto. The difference is that the program below is somewhat simpler as it uses only branches BRZ and BR whereas the program in the lecture notes uses branches BRP BR and BR First, try to understand each instruction thoroughly and then trace the execution of each instruction. Note that the program starts at address
Address Instruction
Mnemonics
IN
STO
BRZ
IN
ADD
STO
LDA
SUB
BR
LDA
OUT
HLT
Address Contents
DAT decremented by each time the loop is executed
DAT
DAT
Assume now that the above program will only read numbers. That is the following numbers in this order will be placed, one at a time, in the Inbasket: and where is the count of numbers that follow, and and are the numbers that are to be added. The first column in the table on page shows the order in which the instructions from the program will be executed. Trace the execution of these instructions and determine the contents of the PC before and after each instruction is executed. Also, write down in the table the contents of the Inbasket; Accumulator; Memory locations and ; and Outbasket after each instruction is executed. Memory location controls the loop. It initially contains an unknown value then next and finally Memory location always contains It is used to decrease the loop count by Memory location is initialized with and finally it stores the sum of and The entry in the PC column means that the PC is when the instruction IN started and is changed to when the instruction IN is finished.The sequence in which instructions
are executed PC
before after Inbasket Accumulator Memory location Memory location Memory location
Outbasket
IN
STO
BRZ
IN
ADD
STO
LDA
SUB
BR
STO
BRZ
IN
ADD
STO
LDA
SUB
BR
STO
BRZ
LDA
OUT
HLT
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
