assignment itech 1000

profilesaifu3446
itech1000assignment2-converted.docx

ITEC 1000 Assignment #2

Total = 100 marks (Solutions);

· 5 marks file name and general format

Instructions:

· All questions are based on Englander -- Chapters 6 & 7.

· Use a word processor (if you use a non-MS WORD compatible program, e.g., Pages, save as PDF or RTF).

· Both questions and answers must be appropriately formatted (including tables) and well presented with enough explanation.

· Be sure to name the file as your full name in the following format (lowercase), e.g., peggy_carter.docx

· Submit via the upload link provided at the course site any time before or by the deadline, March 26, 11 PM (sharp); late submissions will not be accepted.

· Apply the LMC instruction set below to answer relevant questions.

LMC Instruction Set Instruction

Mnemonic

Numeric Code

Load

LDA

5xx

Store

STO

3xx

Add

ADD

1xx

Subtract

SUB

2xx

Input

IN

901

Output

OUT

902

End

HLT

000

Branch/Jump

BR

6xx

Branch if zero

BRZ

7xx

Branch if zero or positive

BRP

8xx

Data storage

DAT

xxx

1. Trace the program below and summarize what the program does; not a step-by-step description of each instruction. [5 marks]

Address / Mailbox #

Assembly / Mnemonic

Numeric Code

00

IN

901

01

STO 90

390

02

IN

901

03

STO 91

391

04

LDA 90

590

05

OUT

902

06

LDA 91

591

07

OUT

902

08

HLT

000

90

DAT 0

000

91

DAT 0

000

2. Complete the table below to construct an LMC program that will accept a set of three numbers as INPUT and then add the first two numbers and output the answer, then subtract the first number from the third and output the answer. The program begins at address 00 and data is stored in address 90. [20 marks]

Mailbox #

Mnemonic

Numeric code

Instruction Description

00

IN

901

Input first number

01

3. Complete the table below and construct an LMC program that will accept a number INPUT and OUTPUT a sequence of numbers, starting at 1 and finishing with the INPUT (maxNumber). The counter must be initialized to zero each time the program is run. The program will continue (loop) until a 0 is entered. [20 marks]

Mailbox #

Mnemonic

Numeric code

Instruction Description

00

load zero (from 93) to the accumulator

01

Store the initial count

02

input

03

If zero, branch to halt

04

Store maxNumber

05

LoopTop load count

06

Add step to counter

07

Store count

08

Output

09

Subtract maxNumber

10

If positive, endLoop

11

Jumpt to loopTop

12

endLoop jump to start

13

Halt execution

90

step DAT 1

91

maxNumber DAT

92

count DAT

93

zero DAT

4. Complete the table below to construct an LMC program that will accept two INPUT numbers and then OUTPUT the greater of the two. The program should begin at address 00 and data should be stored in addresses beginning at 90. [25 marks]

Mailbox #

Mnemonic

Numeric code

Instruction Description

5. Consider the LMC program below in which 2 numbers are entered and added. Suppose the first input entry was stored in mailbox location 00.

a. Would the program have produced the same result?

b. What would have happened if the program were executed a second time?

c. What characteristic of the computer makes this true? [5 marks]

Mailbox

Address

Numeric

Code

00

901

01

306

02

901

03

106

04

902

05

000

06

000

6. If a computer has a 38-bit memory address register. How much memory can this computer address? (Assume: 1 byte/cell; use the most appropriate measure unit). Show your work. [5 marks]

Consider the following LMC instructions found in the given locations in memory.

Mailbox Address

Mnemonic Code

15

LDA 40

16

ADD 41

40

723

41

021

7. Show the CPU Fetch/Execute cycle steps and the values of Instruction Register (IR), the Program Counter (PC), the Memory Address Register (MAR), the Memory Data Register (MDR), and Accumulator (A) when the instruction in address 15 is completed. [5 marks]

F/E cycle

Register Values

8. Show the contents of each register as each step of the F/E cycle is performed for instruction 16 in the above program. [10 marks]

F/E cycle

PC

MAR

MDR

IR

A

PC  MAR

MDR  IR

IR [address]  MAR

A + MDR  A

PC + 1  PC