我在 Keil 上编写了一些汇编代码,如果数组中的元素 < 5,则程序会增加该元素。麻烦的是,ARM 代码不会改变内存中 array1 的值。为此,我需要进行哪些更改?
ADR r0, array1 ; loads address of 'a' to r0
MOV r1, #0 ; r1 = index
L0 CMP r1, #8
BGE stop
LDR r2, [r0, r1, LSL#2] ; load content of array1[index] to r2
CMP r2, #5
ADDLT r2, r2, #1 ; array1[index]++
STRLT r2, [r0, r1, LSL#2] ; store r2 as content of array1[index]
ADD r1, r1, #1 ; index++
B L0
stop B stop
array1 DCD 1, 7, 4, 9, 2, 3, 8, 6
END