The program requires reading the elements of an array of 10 numbers and count the number of zeros in that array and store it in R7. Here's what I've developed so far...
AREA addition, CODE, READWRITE
ENTRY
LDR R0,=ARR
MOV R1, #0 ; Loop Iterator
MOV R2, #0 ; Array Index
MOV R7, #0 ; Number Of Zeros In The Array
LOP CMP R1, #10
BEQ EXT
LDR R3, [R0]
CMP R3, #0
BEQ MOVE1
B CNT
MOVE1 ADD R7, R7, #1
B CNT
CNT ADD R2, R2, #4
ADD R1, R1, #1
B LOP
ARR DCD 3,-5,-1,0,10,0,4,-8,7,6
EXT
END
The problem is that it never enters MOVE1. I really cannot figure out why.
Thanks in advance.
R0
never changes, so the value loaded intoR3
never changes, so the test for your loop always comes out the same way. (And you don't need theB CNT
afterMOVE1
, since that is the next instruction, anyway.)