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

A program that performs a logical shift of a bit pattern to theleft by a certain

ID: 3609707 • Letter: A

Question

A program that performs a logical shift of a bit pattern to theleft by a certain amount (a number between 0 and 16, including 0and 16). The program should assume that the initial bit pattern tobe shifted is in memory location x3100 and the shift amount isstored in memory location x3101. Using those values, your programshould perform the left shift and store the result in locationx3102. The program should start at memory location x3000. I understand that in order to shift leftthat you need to add the same binary number with itself but I needto understand the code more. For example, it should looksomething like this I think ADD R3,R2,R1 please include the LC-3 codewhich is in assembly language. There are only 15 instructionsthat the LC-3 can do. I understand that in order to shift leftthat you need to add the same binary number with itself but I needto understand the code more. For example, it should looksomething like this I think ADD R3,R2,R1 please include the LC-3 codewhich is in assembly language. There are only 15 instructionsthat the LC-3 can do.

Explanation / Answer

             ANDR1, R1, #0 ;zero out the result register

            AND R2, R2, #0 ;R2 will act as a counter

             LD R3, NegSixt

MskLoop AND R4, R0, R5 ;mask off the bit

              BRzNotOne ;if bit is zero then don't increment the result

             ADDR1, R1, #1 ;if bit is one increment the result

              STIR0, PTR1

NotOne ADD R5, R5, R5 ;shift the mask one bit left

            ADDR2, R2, #1 ;increment counter (tells us where we are in bitpattern)

            ADDR6, R2, R3      

           STI R0, PTR2

            BRnMskLoop ;not done yet go back and check other bits

            HALT

NegSixt .FILL #-16

             PTR1 .FILL x3101

      PTR2 .FILL x3102

            .END

I hope this will helps you!!!!!

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