You must do the programming assignment by yourself. You are permitted to get help ONLY from the TAs and the instructor. Instructions on how to submit the assignment will be provided on the webpage soon.
Left-rotate a 16-bit number N by B bit positions
In this assignment, you are asked to write a program in LC-3 machine language to left-rotate a 16-bit word N by a given number of bit positions B, and store the result back in memory. Your program should assume that the word N to be rotated is stored in memory location x3100 and the number of bit positions B is stored in memory location x3101. Your program should store the rotated result in memory location x3102. Your program should start at memory location x3000.
Example: If the memory location x3100 contains the word
0000111100001111, and memory location x3101 contains 0000000000000101, then your program should store the value 1110000111100001
in memory location x3102.
Note: You may assume that the value stored at memory location x3101 (the number of bit positions to left rotate by) is an integer between 0 and 15.
Hint 1: What happens when you add a number to itself? For example 1111000011110000 + 1111000011110000 = 1110000111100000.
Hint 2: How is bit 15 different from the other bits in a word?
Hint 3: Left rotating a 16-bit number by 3 bit positions is the same as left rotating the number by 1 bit position, and then left rotating again by 1 bit position, and then left rotating again by 1 bit position.
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 (Linux) machines you can do this by using the
"Set Values" option on the
menubar and selecting the "Set Register or Memory" option. On Windows
machines, you can click on "Simulate" on the menubar and select "Set Value".
Instead, you can just press F4 and the "Set Value" dialog box will pop up.