Problem 1
Problem 5.2 on page 145 of ItCS using
an addressability of 16 bits.(3 points)
The MDR is 16 bits. The statement does not tell anything about the size of the MAR.
Problem 2
Problem 5.4 on page 145 of ItCS using
memory consisting of 512 locations. (3 points)
- 9
bits.
- We
need to transfer between instructions +-20 locations away. Hence we need
6 bits.
- (PC
+ 1) = 4, hence PC-relative offset = 6.
Problem 3
Problem 5.8 on page 146 of ItCS. (4 points)
Increasing the number of registers
to 32 will need 5 bits to denote the register number. Now, the minimum number
of bits needed for the ADD instruction will be 4 ( for
the opcode ) + 3 registers * 5 bits = 19 bits. This
cannot fit in the 16-bits allocated for an LC-3 instruction.
Problem 4
If the control is redirected to location x4444 after the execution of the following instructions, what should have been the relationship
between R1 and R2 before these instructions were executed? (Please show your steps for solving this problem to receive
full credit) (4 points)
Address
Instruction
x4400
1001100010111111 (NOT R4, R2)
x4401
0001100100100001 (ADD R4, R4, #1)
x4402
0001100001000100 (ADD R4, R1, R4)
x4403
0000100001000000 (BRN x4444)
R4 contains (R1-R2) which is negative. Hence, R1 is less than R2.
Problem 5
Problem 5.9 on page 146 of ItCs using the following three instructions: (3 points)
a) 0101 001 001 0 00
001
AND R1, R1, R1: differs from a NOP
in that it sets the CC’s.
b) 0000 000 000000010
Branch that is never taken. Yes
same as NOP.
c) 0000 111 000000010
BRnzp
#2: Unconditionally branches to 2 locations after the next address in PC. Hence, not the same as NOP.
Problem 6
Problem 5.13 on page 147 of ItCS. (5 points)
- 0001
011 010 1 00000 (ADD R3, R2, #0)
- 1001
011 011 111111 (NOT, R3, R3)
0001 011 011
1 00001 (ADD R3, R3, #1)
0001 001 010 0 00011 (ADD, R1, R2,
R3)
- 0001
001 001 1 00000 (ADD, R1, R1, #0)
- Can’t
happen. The condition where N=1, Z=1 and P=0 would require the contents
of a register to be both negative and zero.
- 0101
010 010 1 00000 (AND R2, R2, #0)
Problem 7
Problem 5.14 on page 147 of ItCS. (3 points)
(2): 1001 101 010 111111
(4): 1001 011 110 111111
Problem 8
The PC contains x3010. The following memory locations contain values as shown (3 points):
x3050: x70A4
x70A2: x70A3
x70A3: xFFFF
x70A4: xABCD
The following three LC-3 instructions are then executed, causing a value to be loaded into R6.
What is that value? (Show your steps to receive full credit)
x3010 1110 0110 0011 1111 (LEA R3,
x3050: R3 gets the value x3050)
x3011 0110 1000 1100
0000 (LDR R4, R3, #0: R4 gets the value x70A4)
x3012 0110 1101 0000 0000 (LDR R6,
R4, #0: R6 gets the value xABCD)
xABCD is loaded into R6
We could replace the three instruction sequence with a single instruction. What is it ?
These three instructions could be replaced by the following single instruction at location x3010:
x3010 1010 1100 0011 1111
Problem 9
The purpose of this problem is to get you setup with the LC-3 simulator, which will be important for subsequent homeworks. You can get the
LC-3 simulator in one of the following ways:
- Unsupported PC Use:You can download and extract the LC-3 Simulator on your own personal computer.
However, we cannot support any problems encountered and you are on your own.
Nevertheless, many students in previous semesters preferred this option.
- Supported CAE Account:You can access the LC-3 simulator in CAE machines if you have a CAE account. To add the LC-3 simulator to
your CAE applications, go to START->'CAE Applications'->'Add Applications to Start Menu'->
'Available Applications'->'By Alphabetical'->G-L and select LC-3 Editor and LC-3 Simulator. Then you can open
LC-3 simulator from 'START'->'CAE Applications'->'Engineering'->'LC-3 Simulator'.
- Supported CS Account (Lecture 3 only):If you are officially enrolled in 252 with a CS professor (Hill), a CS account has been created for you, and you can log on
to any CS Instructional Windows machine in rooms 1351 and 1368 in Computer Science and Statistics (CSS). Please check Computer Science Lab (CSL) Getting Started
for information about activating your CS account. If you don't have an account please go to CSL on the
2nd floor. After logging in you can open the LC-3 Simulator from 'START'->'All
Programs'->'LC3'->'Simulate'.
After opening the LC-3 simulator, please report the following (2 points):
- The names of the LC-3 registers that can be seen in the simulator window.
R0, R1, R2, R3, R4, R5, R6, R7, PC, IR, PSR, CC
- The starting memory address, as shown by the blue arrow.
x3000