Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem solving using computer involves data processing that includes many types

ID: 3766272 • Letter: P

Question

Problem solving using computer involves data processing that includes many types of operations on data stored in computer storages. In this lab, we will perform some basic data processing such as shift and rotate.

Procedure:

Shift and rotate operation for memory contents

In this part, you are asked to write a program in LC-3 machine language to shift/rotate 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/rotate is called the shift/rotate amount. Shift amount is a non-negative number between 0 and 16, inclusive.

Your program should assume that:

The initial bit pattern to be shifted if in memory location x3100.

The shift/rotate amount n is in memory location x3101.

Use those values to perform the left shift/rotate.

In shift operation, fill the lowest n bits of the bit pattern with 0’s. In rotate operation, the top n bits rotate into the lowest n bits.

Store the result in memory location x3102.

Explanation / Answer

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 0's.

6 + 6 = 6 * 2 => 0110 + 0110 = 1100 (0011 shifted 2 times)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote