[SOLVED] LC-3: CPS2390 lab 2

$25

File Name: LC-3:_CPS2390_lab_2.zip
File Size: 178.98 KB

5/5 - (1 vote)

Department of Computer Engineering
Wenzhou-Kean University
CPS2390, Fall 2016

Due Date: Oct 20, 2016

Instructions:
1. You should do the programming assignment by yourself. Instructions on how to
submit the assignment is provided at the end of this handout.

2. There are two parts to this assignment. In each part you will be asked to write a
different program. You will therefore submit two programs, one for Part 1 and
one for Part 2. Both programs should be written in LC-3 machine language. Read
the instructions carefully and make sure you follow them.

Part 1 A Program that shifts a bit pattern to the left by a certain amount (a
number between 0 and 16, including 0 and 16)

Problem: In this part, you are asked to write a program in LC-3 machine language to
shift a bit pattern some number of bits to the left and store the result in memory. The
number of bits the bit pattern should be shifted is called the shift amount. Shift amount is a non-negative number between 0 and 16, inclusive (that is 0 and 16 are valid shift amounts). Your program should assume that the initial bit pattern to be shifted is in memory location x3100 and the shift amount is stored in memory location x3101. Using those values, your program should perform the left shift and store the result in memory location x3102. Your program should start at memory location x3000.

Example: If the memory location x3100 contains the bit pattern 1101000100001011 and memory location x3101 contains the value 0000000000000101 (decimal 5), then your program needs to shift 1101000100001011 5 bits to the left and store the bit pattern 0010000101100000 in memory location x3102. Note that when you shift a bit pattern n bits to the left, you fill the lowest n bits of the bit pattern with 0s.

Hint: What happens when you add a number to itself?

Simulator Hint: You can test your program by setting the values of memory locations x3100 and x3101 before you run your program on the LC-3 simulator. On UNIX machines (Sun, Linux) you can do this by using the Set Values option on the menu bar and selecting the Set Register or Memory option. On Windows machines, you can click on Simulate in menu bar and select Set Value. Instead, you can just press F4 and the Set Value dialog box will pop up.

Part 2 A Program that rotates a bit pattern to the left by a certain amount (a
number between 0 and 16, including 0 and 16)

Problem: Now that you have done the left shift, well ask you to do something more
exciting: rotating a bit pattern. Your task in this part is to write a program in LC-3
machine language to rotate a bit pattern some number of bits to the left and store the
result in memory. The rotate amount (number of bits you rotate the bit pattern to the left) is a non-negative integer between 0 and 16, inclusive. Your program should assume that the initial bit pattern is in memory location x3100 and the rotate amount is stored in memory location x3101. Using those values, your program should perform the left rotation and store the result in memory location x3102. Your program should start at memory location x3000.

Example: If the memory location x3100 contains the bit pattern 1101000100001011 and memory location x3101 contains the value 0000000000000101 (decimal 5), then your program needs to rotate 1101000100001011 5 bits to the left and store the bit pattern 0010000101111010 in memory location x3102. Note that when you rotate a bit pattern n bits to the left, it is just like a left shift except that top n bits before the shift end up as the bottom n bits.

Notes and Suggestions:
The first line of your programs must specify the memory address of the first
instruction of your program. LC-3 simulator will place your program starting at
that address. For this assignment, you should place your program starting at
x3000 (the first line of your program should contain the bit pattern
0011000000000000).
If you are using a Windows machine, use the LC3Edit program to type in your
programs. On Sun and Linux workstations, pico, emacs, and vi are several of the
text editors you can use. Your program file needs to be in plain text format.

Your code should have a comment block at the beginning of the file containing your name, your student number, and a brief description of the program.
Your description should serve as a general summary of your programs approach to the problem and will aid in grading. It will also serve as a guideline for assigning partial credit. It is in your best interest to make all of your ideas clear through this summary and through commenting within your code.

Put the above info to a text file named: lab2_readme.txt.
Put your code in lab2.bin

What to turn in

Please put all your files (lab2.bin, lab2.obj, and lab2_readme.txt) in a zip file (Lab2_youlastname_firstname.zip) and send it to [email protected] before due date.

Grading: 85% for correct values, 15% for commenting.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] LC-3: CPS2390 lab 2
$25