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.
Perform addition on two unsigned 8-bit numbers
In this assignment, you are asked to write a program in LC-3
machine language to add two 8-bit unsigned numbers and store the result back in memory.
The two 8-bit unsigned numbers are specified in memory location x3100 as follows -
Bits [15:8] - First number
Bits [7:0] - Second number
Your program should store the result of the specified operation in memory location x3101.
Note: Unsigned numbers are always positive. That is, with 8 bits we can
represent unsigned integers from 0 to 255.
Example: If the memory location x3100 contains the word
0000111111111100, then your program should add 15 and 252 and store the value 267 (100001011)
in memory location x3101.
Hint 1: Use bit masks 0x00FF and 0xFF00 to separate the two 8-bit numbers.
Hint 2: What happens when you add a number to itself? For example 0001110001110001 + 0001110001110001 = 0011100011100010.
Hint 3: We say a bit string is "shifted" to the left one bit if, for each bit, the result of bitstring[i] is what the original contents of bitstring[i-1] was before the shifting. The result of bitstring[0] is 0. We say a bit string is "rotated" to the left one bit if, after shifting, we make the result of bitstring[0] equal to the original contents of bitstring[15].
Simulator Hint: You can make use of bit-masks stored in memory by setting the values of the memory locations immediately after the HALT instruction of your program to appropriate bit-masks before you run it on the LC-3 simulator.
Testing: Test your program by running it multiple times on the LC-3
simulator, each time setting the value of memory location x3100 with
different bit pattern.
Notes: