The following program supposed to determine whether a sequence of memory locatio
ID: 647207 • Letter: T
Question
The following program supposed to determine whether a sequence of memory locations contains a 5 or not. It stores a 1 in R0 if 5 was found, and it stores a 0 in R0, otherwise, but the program fails to do so. Identify the error and explain how to fix it?
.ORIG x3000
AND R0, R0, #0
ADD R0, R0, #1
AND R1, R1, #0
ADD R1, R1, #-5
AND R3, R3, #0
ADD R3, R3, #4
LD R4, PTR
LDR R2, R4, #0
AGAIN ADD R2, R2, R1
BRz FIN
ADD R4, R4, #1
ADD R3, R3, #-1
LDR R2, R4, #0
BRp AGAIN
AND R0, R0, #0
FIN HALT
PTR .FILL x3015
.END
Explanation / Answer
it seems fine
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.