CS/ECE 252 Introduction to Computer Engineering Spring 2009 All Sections |
Homework
5 // Due at lecture Mar 30, Mon
Primary contact for this homework:
Mengmeng Chen [mchen at cs
dot wisc dot edu]
You may choose to do this homework in a group of TWO or THREE
students or all by yourself. If you do it in a group, each of the group member
should hand in ONE copy of the homework that lists the common section number
and names and UW ID numbers of all the other students. Please staple multiple pages together.
Program
1.
Problem 5.5 on page 145 of ItCS.
Program
2.
Problem 5.12 on page 145 of ItCS.
Program
3.
The program counter contains the address of an LDR instruction. In order for the LC-3 to process that instruction, how many memory accesses must be made? Repeat this task for STI and TRAP
Problem
4.
Suppose the following LC-3 program is loaded into memory starting at location x30FF:
X30FF 1110 0010 0000 0001
X3100 0110 0100 0100 0010
X3101 1111 0000 0010 0101
X3102 0001 0100 0100 0001
X3103 0001 0100 1000 0010
If the program is executed, what is the value in R2 at the end of execution?
Problem
5.
Write an LC-3 program that compares two numbers in R2 and R3 and puts the larger number in R1. If the numbers are equal, then R1 is set equal to 0.
Note: for this question, you should put your code into a ASCII file and send it to me (mchen@cs.wisc.edu) directly. Your filename should be xxxxxxxxxx(this would be your student id number).asm. The title of your email should be [cs252]homework5_[yourfirstname]_[youfamilyname] (i.e., [cs252]homework5_tom_smith). Attach your file with the email and nothing else. Make sure you follow the requirement strictly so that your email won't get lost.
Problem
6.
An LDR instruction, located at x3200, uses R4 as its base register. The value currently in R4 is x4011.
(a) What is the largest address that this instruction can load from?
(b) Suppose we redefine the LDR offset to be zero-extended unsigned number, rather than sign-extended 2’s complement number. Then what would be the largest address that this instruction could load from?
(c) With the new definition, what would be the smallest address that this instruction could load from?
Problem 7.
Problem 5.30 on page 150 of ItCS.
Problem
8.
Problem 5.26 on page 149 of ItCS. Skip the questions (c) and (d) from the book. Instead, answer the following two questions:
(c) Given the
constraints, which instructions can’t be implemented correctly?
(d) How far forward
and backward can the branch instruction go with this new format?
Problem
9.
The purpose of this problem is to get you setup with the LC-3 simulator, which will be important for subsequent homework. You can get the LC-3 simulator in one of the following ways:
1. 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.
After opening the LC-3 simulator, please report the following: