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

The two code sequences A and B are assembled separately. There is one error that

ID: 3836383 • Letter: T

Question

The two code sequences A and B are assembled separately. There is one error that will be caught at assembly time and the other error will be caught at link time. Identify each error and explain why the bug will cause an error and whether it will be detected at assemble or link time.

.orig x3200

SQRT1   ADD RO,R0,#0

     ; Code to perform square root function and return result in R0

RET

.END

      B     .EXTERNAL SQRT

             .orig x3000

             LD R0,VALUE

             JSR SQRT

             ST R0,DEST

             HALT

             VALUE .FILL x3000

             DEST      .FILL x0025

             .END

.ORIG X3005
                  LEA R2, DATA
                  LDR R4, R2, #0
LOOP       ADD R4, R4, #-3
                  BRzp LOOP
DATA       .FILL x000B
                 .END

When the LC3 program is executed, how many times will the instruction at the memory address labeled LOOP execute? Show all work.

Explanation / Answer

In the first program.

There is a difference in the subroutine name defined and used its 'SQRT1' not 'SQRT' this will be detected at assembly time.

And also R0 is not initialized before it can be used, this can only be detected at run time.