Распределение памяти (DCD
) выполняется в той же области, что и объявление кода.Это означает, что он, вероятно, будет использоваться, как если бы был установлен AREA PROGRAM, CODE, READONLY
, и как таковой кеил не будет его собирать.Это также означает, что если он был собран, расположение данных будет READONLY
.Надлежащему объявлению переменных будет предшествовать AREA <a section name>, DATA, READWRITE
Main
LDR R1, =Value1 -- load Value1 inside R1
LDR R2, =Value2 -- load Value2 inside R2
LDR R1,[R1] -- load indirect the address pointed to by the value of R1 to R1 -- (I have reservations about the functionality of this code)
LDR R2,[R2] -- load indirect the address pointed to by the value of R2 to R2 -- (I have reservations about the functionality of this code)
Return
ANDS R3, R1,R2 -- R3 = R1 AND R2
BNE SEND -- branch if not equal to SEND label
BEQ NEXT -- branch to NEXT if equal
END
SEND
LDR R4, =Result -- load Result to R4
LDR R4,[R4] -- load indirect the address pointed to by the value of R4 to R4 -- (I have reservations about the functionality of this code)
STR R3, [R4] -- store indirect to address pointed to by the value of R4 with the value of R3
END
NEXT
MOV R1, R2 -- copy R2 to R1
LDR R2, =Value3 -- load Value3 to R2
LDR R2, [R2] -- load indirect the address pointed to by the value of R2 to R2 -- (I have reservations about the functionality of this code)
B Return -- unconditional branch to Return label
END
Value1 DCD &0202 -- word allocation with hex value of
Value2 DCD &0101 -- word allocation with hex value of
Value3 DCD &0001 -- word allocation with hex value of
Result DCD &FFFFFFF0 -- word allocation with hex value of
Этот код пытается сохранить тот факт, что r2
и r1
равны или бесконечный цикл произойдет из-за статической природызначения, сохраненные внутри Value<1-3>