Question: 3 . Below is a Little Man program that solves exercise 6 . 9 , p . 1 6 4 , from textbook. The program

3. Below is a Little Man program that solves exercise 6.9, p.164, from textbook. The program is very similar to the LMC program which you will find in the lecture notes on Chapter 6 posted on Blackboard and discussed in Panopto. The difference is that the program below is somewhat simpler as it uses only 2 branches (BRZ 19 and BR 11), whereas the program in the lecture notes uses 3 branches (BRP 05, BR 10, and BR 01). First, try to understand each instruction thoroughly and then trace the execution of each instruction. Note that the program starts at address 10.
Address Instruction
(Mnemonics)
10 IN
11 STO 25
12 BRZ 19
13 IN
14 ADD 27
15 STO 27
16 LDA 25
17 SUB 26
18 BR 11
19 LDA 27
20 OUT
21 HLT
Address Contents
25 DAT ?->2->1->0(decremented by 1 each time the loop is executed)
26 DAT 1
27 DAT 0
Assume now that the above program will only read 3 numbers. That is, the following numbers in this order will be placed, one at a time, in the In-basket: 2,18, and 15, where 2 is the count of numbers that follow, and 18 and 15 are the numbers that are to be added. The first column in the table on page 4 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 In-basket; Accumulator; Memory locations 25,26, and 27; and Out-basket after each instruction is executed. Memory location 25 controls the loop. It initially contains an unknown value (?), then 2, next 1, and finally 0. Memory location 26 always contains 1. It is used to decrease the loop count by 1. Memory location 27 is initialized with 0, and finally it stores 33, the sum of 18 and 15. The entry 1011 in the PC column means that the PC is 10 when the instruction IN started and is changed to 11 when the instruction IN is finished.The sequence in which instructions
are executed PC
before after In-basket Accumulator Memory location 25 Memory location 26 Memory location
27 Out-basket
IN 101122?10?
STO 25020322?10?
BRZ 19
IN
ADD 27
STO 27
LDA 25
SUB 26
BR 11
STO 25
BRZ 19
IN
ADD 27
STO 27
LDA 25
SUB 26
BR 11
STO 25
BRZ 19
LDA 27
OUT
HLT
 3. Below is a Little Man program that solves exercise 6.9,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!