No scores will be given without a comprehensible explanation.

Introduction to Computers
-2nd exam授課教師: 李錫智 教授
1.[5]An imaginary computer has sixteen data
registers (R0 to R15), 256 words in memory,
and 16 different instructions (add, subtraction,
and so on). Assuming one word corresponds to
one distinct address. What is the minimum size
of an instruction in bits if a typical instruction
uses the format of add R1, R2, R3 or load R1, M?
Why? No scores will be given without a
comprehensible explanation.
Ans:
sixteen data registers  24 = 16 4 bits
256 words in memory 28 = 256 8 bits
16 different instructions  24 = 16 4 bits
Minimum = 4 + 8 + 4 = 16 bits
2.[5] If the computer in Problem 1 uses the
same size of word for data and instructions,
what is the minimum size of each data register
in bits? Why? No scores will be given without a
comprehensible explanation.
Ans: 16 bits, because the minimum size of an
instructions is 16 bits.
3.[5] If the computer in Problem 1 uses the
same size of word for data and instructions,
what is the minimum size of each word in bits
in the memory? Why? No scores will be given
without a comprehensible explanation.
Ans: 16 bits, because the minimum size of an
instructions is 16 bits.
4.[5] What is the minimum size of the
instruction register in the computer in Problem
1? Why? No scores will be given without a
comprehensible explanation.
Ans: 16bit, because the minimum size of an
instruction is 16 bits
5.[5] What is the size of the program counter in
the computer in Problem 1? Why? No scores
will be given without a comprehensible
explanation.
Ans: 256 words in memory  256 = 28 8 bits
6.[5] How many wires at least required for the
data bus in the computer in Problem 3? Why?
No scores will be given without a
comprehensible explanation.
Ans: 16 wires, because the minimum size of
each word in bits in the memory is 16 bits.
7.[5] How many wires required for the address
bus in the computer in Problem 1? Why? No
scores will be given without a comprehensible
explanation.
Ans: 8 wires, 256 words in memory  256 = 28
8.[5] A monoprogramming operating system
runs programs that on average need 20% of the
time in access to the CPU and 80% of the time
in access to the I/O devices. What percentage
of time is the CPU idle? Why? No scores will be
given without a comprehensible explanation.
Ans: 80% , because the program used 80% of
the time in access to the I/O devices.
9.[10] A multiprogramming operating system
uses partitioning for its memory management
to divide the 100 MB of its memory into four
partitions of 40 MB, 20 MB, 10 MB, and 30 MB.
The first program to be run needs 24 MB, the
second program needs 7 MB, the third program
needs 11 MB, and the fourth program needs 32
MB. Suppose all the four programs are running.
What is the total memory used? What
percentage of memory is wasted (wasted/total),
i.e., cannot be used by upcoming programs?
Ans:
Partitions(MB)
Used Memory(MB) Wasted Memory(MB)
40
32(4th program)
8
20
11(3rd program)
9
10
7(2nd program)
3
30
24(1st program)
6
Used memory = 32 + 11 + 7 +24 = 74MB
Wasted / Total = ( 8 + 9 + 3 + 6 ) / 100 = 26%
10.[10] A multiprogramming operating system,
having 100 MB of memory, uses paging for its
memory management. Each frame (page) is 2 MB.
The first program to be run needs 24 MB, the
second program needs 7 MB, the third program
needs 11 MB, and the fourth program needs 32
MB. Suppose all the four programs are running.
What is the total memory used? What percentage
of memory is wasted (wasted/total), i.e., cannot
be used by upcoming programs?
Ans: Used Memory = 24 + 7 + 11 + 32 = 74 MB
Wasted / Total = 2 / 100 = 2 %
11.[10] Using the instruction set of the simple
computer in Section 5.7, write the code for a
program that performs the following
calculation:
D = 4A
where A is an integer stored in the memory
with address 7E and D is stored in address B5.
Note that each instruction is represented by a
string of bits.
Ans:
107E 
3000 
3000 
2B50 
0000 
LOAD
ADDI
ADDI
STORE
HALT
R0
R0
R0
B5
7E
R0
R0
R0
R0
R0
12. [10] Consider the following program:
1040
A000
A000
A000
2410
0000
What does this program do?
Ans:
1040 
A000 
A000 
A000 
2410 
0000 
LOAD
INC
INC
INC
STORE
HALT
R0
R0
R0
R0
41
40
R0
13.[10] Consider the following program:
104A
114B
6110
A100
124C
3310
3432
24D4
0000
Suppose 7 is stored in the memory with address 4A, 5 is
stored in the memory with address 4B, and 3 is stored in
the memory with address 4C. What value is stored in the
memory with address 4D after the program is executed.
Ans:
104A
114B
6110
A100
124C
3310
3432
24D4
0000









LOAD
LOAD
NOT
INC
LOAD
ADDI
ADDI
STORE
HALT
R0
R1
R1
R1
R2
R3
R4
4D
// R0 = 7
// R1 = 5
4A
4B
R1
4C
R1
R3
R4
R0
R2
// R1 = -5 (Two’s complement)
// R2 = 3
// R3 = R1 + R0 = -5 + 7 = 2
// R4 = R3 + R2 = 2 + 3 = 5
// 4D = 5
14.[10] Consider the following program:
10FE
5100
3000
3201
2FF2
0000
Note that the address of the keyboard is FE and the
address of the monitor is FF. Suppose you run this
program and type in 3 from the keyboard. What value
will you see on the monitor after the program stops?
Ans:
10FE
5100
3000
3201
2FF2
0000






LOAD R0
MOVE R1
ADDI R0
ADDI R2
STORE FF
HALT
// R0 = 3
FE
R0
// R1 = 3, R0 = 3
R0 R0 // R0 = R0 + R0 = 3 + 3 = 6
R0 R1 // R2 = R0 + R1 = 6 + 3 = 9
R2
// FF = 9