Question: The Little Man program below uses only 2 branches (BRZ 09 and BR 01). Assume now that the program will only read 3 numbers. That

The Little Man program below uses only 2 branches (BRZ 09 and BR 01). Assume now that the program will only read 3 numbers. That is, the following numbers in the following order will be placed, one at a time, in the In-basket: 2, 15, and 10, where 2 is the count of numbers that follow, and 15 and 10 are the numbers that are to be added. The first column in the table below 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 12 through 14, and Out-basket after each instruction is executed. Memory locations 13 and 14 are initialized with 1 and 0, respectively. The contents of memory location 12 is initially unknown. The entry 00 01 in the PC column means that the PC is 00 when instruction IN started and is changed to 01 when the IN instruction is finished. The instructions at addresses 00-11 represent the program area and the addresses 12-14 represent the data area.

Address Instruction Mnemonics

00 IN

01 STO 12

02 BRZ 09

03 IN

04 ADD 14

05 STO 14

06 LDA 12

07 SUB 13

08 BR 01

09 LDA 14

10 OUT

11 HLT

------------------------

Address Contents

12 DAT ? // stores the current count; 2, 1, 0; initially (?), at the end 0.

13 DAT 1 // constant 1; used to control the loop; decrements the count by 1.

14 DAT 0 // stores the partial and then the final sum; initially 0, at the end 25.

The sequence in which instructions

are executed

PC

before after

In-basket

Accumulator

Memory location 12

Memory location

13

Memory location

14

Out-basket

IN

00 01

2

2

?

1

0

?

STO 12

BRZ 09

IN

ADD 14

STO 14

LDA 12

SUB 13

BR 01

STO 12

BRZ 09

IN

ADD 14

STO 14

LDA 12

SUB 13

BR 01

STO 12

BRZ 09

LDA 14

OUT

HLT

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!