28.04.2014 Views

Adobe PDF

Adobe PDF

Adobe PDF

SHOW MORE
SHOW LESS

Transform your PDFs into Flipbooks and boost your revenue!

Leverage SEO-optimized Flipbooks, powerful backlinks, and multimedia content to professionally showcase your products and significantly increase your reach.

CPSC 2105<br />

Computer Organization<br />

Homework Set 3 Due Thursday, October 7, 2010<br />

NOTE: SHOW ALL OF YOUR WORK. YOU MUST DEMONSTRATE THAT YOU<br />

UNDERSTAND THE PROCESS OF OBTAINING AN ANSWER.<br />

DO NOT PUT ANY ANSWERS ON THIS QUESTION SHEET.<br />

1. Exercise 4 on page 237 of the textbook.<br />

How many bits are required to address a 4M x 16 main memory if<br />

a) main memory is byte addressable<br />

b) main memory is word addressable<br />

ANSWER: 1M = 2 20 , so 4M = 42 20 = 2 22 and 8M = 2 23 .<br />

One 16–bit word will contain two 8–bit bytes. To convert from word count to byte<br />

count in a byte addressable memory, multiply the word count by the number of bytes<br />

per word. Here there are two bytes per word.<br />

a) If memory is byte addressable, there are 2 23 bytes. This requires 23 bits to address.<br />

b) If memory is word addressable, there are 2 22 words. This requires 22 bits to address.<br />

NOTE:<br />

Individual bits are not addressable. Admittedly, the memory contains<br />

4M 16 = 2 22 2 4 = 2 26 bits, but it is the byte or word count that is<br />

used for the addressing.<br />

2. Exercise 5 on page 237 of the textbook.<br />

How many bits are required to address a 1M x 8 main memory if<br />

a) main memory is byte addressable<br />

b) main memory is word addressable<br />

ANSWER: 1M = 2 20 , 512K = 2 19 , and 256K = 2 18 .<br />

a) If memory is byte addressable, there are 2 20 bytes, requiring 20 address bits.<br />

b) 2 20 8–bit bytes is the same as 2 19 16–bit words or 2 18 32–bit words.<br />

I view this question as ambiguous, and will give credit for 18, 19, or 20.


3. Exercise 7 on page 238 of the textbook.<br />

Suppose that a 16M x 16 main memory is build using 512K x 8 RAM chips.<br />

a) How many RAM chips are necessary<br />

b) How many RAM chips are there per memory word<br />

c) How many address bits are needed for each RAM chip<br />

d) How many address bits are needed for all of memory<br />

e) If high–order interleaving is used, where would address 14 (which is E in hex)<br />

be located<br />

f) If low–order interleaving is used, where would address 14 (which is E in hex)<br />

be located<br />

ANSWER: 1M = 2 20 , 512K = 2 19 , and 16M = 2 4 2 20 = 2 24 .<br />

a) The number of bits in the main memory is 16M16 = 2 24 2 4 = 2 28 .<br />

The number of bytes in the main memory is 16M2 = 2 24 2 1 = 2 25 .<br />

The number of bits in each RAM chip is 512K8 = 2 19 2 3 = 2 22 .<br />

The number of bytes in each RAM chip is 512K = 2 19 .<br />

The chip count is either 2 28 / 2 22 = 2 6 , or 2 25 / 2 19 = 2 6 . In either case, it is 64 chips.<br />

b) Each memory word is spread into two RAM chips.<br />

One stores bits 15 – 8, and the other bits 7 – 0 of the memory word.<br />

c) Each RAM chip is 512K = 2 19 , so it requires 19 address bits.<br />

d) Each 512K x 8 RAM chip is a part of a 512K x 16 memory bank.<br />

The number of memory banks is 16M / 512K = 2 24 /2 19 = 32 memory banks.<br />

Five bits are required to select the memory bank.<br />

e) Main memory has 16M = 2 24 addressable units, so 24 address bits are needed.<br />

5 bits go to select the memory bank, and 19 bits are sent to each memory bank.<br />

f) In high–order interleaving, the first 512K addresses are placed in bank 0.<br />

That is the location of address 14.<br />

g) For low–order interleaving, we must examine the structure of the 24–bit address.<br />

Address 0x0E is 0000 1110 in binary.<br />

Bit 23 – 8 7 6 5 4 3 2 1 0<br />

0000 0000 0000 0000 0 0 0 0 1 1 1 0<br />

19–bit offset in the bank<br />

5–bit bank number<br />

The address is in bank 0x0E or bank 14.


4. Exercise 13 on page 239 of the textbook.<br />

List the hexadecimal code for the following program (hand assemble it).<br />

Address Label Instruction<br />

100 Load A<br />

101 Add One<br />

102 Jump S1<br />

103 S2, Add One<br />

104 Store A<br />

105 Halt<br />

106 S1, Add A<br />

107 Jump S2<br />

108 A, HEX 0023<br />

109 One, HEX 0001<br />

ANSWER: Here I elect to do the assembly in the fashion of a two–pass assembler.<br />

The first pass identifies the labels and associates an address with each.<br />

Here is the symbol table produced by the first pass of the assembler.<br />

Label Address<br />

A 108<br />

One 109<br />

S1 106<br />

S2 103<br />

At this point, the partially assembled code would appear as follows.<br />

Address Label Instruction Result So Far<br />

100 Load A Load 108<br />

101 Add One Add 109<br />

102 Jump S1 Jump 106<br />

103 S2, Add One Add 109<br />

104 Store A Store 108<br />

105 Halt Halt<br />

106 S1, Add A Add 108<br />

107 Jump S2 Jump 103<br />

108 A, HEX 0023 0023<br />

109 One, HEX 0001 0001


Using the modified opcodes, we have<br />

Load 01 Add 03 Halt 00<br />

Store 02 Jump 09<br />

Address Label Instruction Result So Far<br />

100 Load A 1108<br />

101 Add One 3109<br />

102 Jump S1 9106<br />

103 S2, Add One 3109<br />

104 Store A 2108<br />

105 Halt 0000<br />

106 S1, Add A 3108<br />

107 Jump S2 9103<br />

108 A, HEX 0023 0023<br />

109 One, HEX 0001 0001<br />

NOTE:<br />

The full assembly listing should be given in the exact order in which the<br />

instructions appear in the program.<br />

5. Consider the following memory contents.<br />

Hex Address Contents<br />

200 220<br />

220 240<br />

If the accumulator has value 1 at the start of each instruction, then<br />

a) What value does the AC have after executing the instruction AddM 200<br />

This is the immediate add instruction.<br />

b) What value does the AC have after executing the instruction Add 200<br />

This is the standard (direct address) add instruction.<br />

c) What value does the AC have after executing the instruction AddI 200<br />

This is the indirect address add instruction.<br />

ANSWER: The AC initially has a value of 1.<br />

a) AddM is an add immediate. It adds 200 to the value to get 201 in the AC.<br />

b) The effect of the Add instruction is depicted by AC AC + M[200].<br />

The value at location 200 is 220, so the AC gets 1 + 220 = 221 in the AC.<br />

c) The effect of this Add instruction is depicted by AC AC + M[ M[200] ].<br />

The value M[200], in address 200, is the address of the value to add to the<br />

AC. As M[200] = 220, the effect is AC AC + M[220].<br />

The value at location 220 is 240, so the AC gets 1 + 240 = 241 in the AC.<br />

NOTE: The result is the same in octal, decimal, or hexadecimal arithmetic.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!