Unformatted text preview: CS 252 Introduction to Computer Engineering, Fall ‘17
Homework 5 Student Details: Student Name: ___________________
Net ID: ___________________ Course Details:
Sections 2 and 5
Instructor: Prof. Adil Ibrahim
TAs: Lan Bai, Amogh Joshi, Gautham Sunjay, Huawei Wang, Ammar Mahmood
Homework to be submitted individually. Please write your Name, Section and NetID on all
pages and staple all pages together before submission. Problem 1 (2 points)
Suppose we increase the number of registers in the LC-3 to 128 and keep the instruction size at
16 bits. Will this cause any problems with the ADD (non-immediate) instruction? Explain. Problem 2 (3 points)
How many times does the LC-3 make a read or write request to memory during the processing
of following instructions?
LEA Student Details: Student Name: ___________________
Net ID: ___________________ Problem 3 (4 points)
Write the LC-3 machine instructions in hex that will implement the following. Give a solution that
is 1-2 instructions long and uses a minimal number of registers.
● Suppose PC = 0x2000 and R1 = 0x3000. Store the 1's complement of the value at
memory address 0x3003 into R2 without overwriting R1.
● Assume PC = 0x4000 and the value at memory address 0x400A is 0x8000. Store the
most significant bit of R2 into R0. Student Details: Student Name: ___________________
Net ID: ___________________ Problem 4 (8 points)
a)Write what each instruction does in the “comment” section. The first one is completed for you
Address Instruction Comment X0123 1110 0001 1111 1011 R0 <- PC - 5 X0124 0001 0010 0010 1010 X0125 0011 0011 1111 1011 X0126 0101 0010 0110 0000 X0127 0001 0010 0110 0100 X0128 0111 0010 0000 1010 X0129 1010 0101 1111 0111 b) What is the value stored in R2 and PC at the end of execution of all the commands? Problem 5 (8 points)
a. Give the instructions JMP, AND, LD and NOT, identify whether they are operate
instructions, data movement instructions or control instructions.
b. List all the addressing modes that can be used with the instructions mentioned above. Student Details: Student Name: ___________________
Net ID: ___________________ Problem 6 (3 points)
The LC3 instruction set does not have an opcode for the logical function NOR. However, this
can be implemented with the existing instructions. Given two numbers already stored in
registers R1 and R2, list down the instructions required to perform NOR on the contents of R1
and R2. Store the result in any of the other registers. Instruction Comment Problem 7 (3 points)
Assume the current value in the PC to be x4012.
a. Write the BR instruction to unconditionally branch to the instruction located at an offset
b. What will the PC point to after the BR statement in (a) is executed? Show the
c. If unconditional branching is possible using B
R, why do we need the JMP instruction? ...
View Full Document
- Spring '13