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

3. The following program is intended to do a logical left- shift of register R1

ID: 2265914 • Letter: 3

Question

3. The following program is intended to do a logical left- shift of register R1 five times, but it has a bug ORIG x3000 AND ADD BRz ADD ADD BR TRAP R0, R0, R0 , R0, DONE R0 , R0, R1, R1, SHIFT x25 #0 #5 4 SHIFT #-1 R1 DONE END a. ldentify the error, the line number where it occurs, and explain how to fix it. For your convenience, all lines have been numbered. We will not read more than 30 words. b. Write a symbol table for the code above before you tried to fix it. Your symbol table should be similar in nature to that produced by the LC-3 assembler: for each label that appears in the code, your table should list the label and associate the label with an address in LC-3 memory. For an example, see P&P; Section 7.3.3, pp. 186-187

Explanation / Answer

Answer:- In real counter R0 should not be decremented first. The code flow should be written as-(from line 4 to 8)

SHIFT ADD R1, R1, R1 ; shift left once means double the value, so adding to make the value double

ADD R0, R0, #-1 ; decrement the counter by one

BRz DONE ; if counter is zero then go to label name done

BR SHIFT ; if not zero then go to label name SHIFT to repeat the operation

For answer of part b, please add the add the exmple section 7.3.3, Thanks.

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