I have to complete the program framework below to calculate the sum of only those values in the data area divisible by 8 and store the result in register r5. My program must be able to work for any number of data values (within memory and 32-bit integer range limits) and it must be possible for a user to change only the values in the data area and the program will continue to work correctly.
THUMB
AREA RESET, DATA, READONLY
EXPORT Vectors
EXPORT Reset_Handler
Vectors
DCD 0x20001000 ; top of the stack
DCD Reset_Handler ; reset vector - where the program starts
AREA Task2Code, CODE, READONLY
ENTRY
Reset_Handler
num EQU 51
MOV r1,#0
MOV r5,#0
LDR r8,=sum_up
loop
MOV r2, r1, ROR #3 ; divide by 8
LDR r2,[r8],#4
ADD r5,r5,r2
ADD r1,r1,#1
CMP r1,#num
B loop
terminate
B terminate
sum_up
DCD -16,100,-456,7,-123,-42,126789,2349,-34,-2344,45,-45,-3345 ; example values
END
This is the code I have made so far but I cannot get it to run, nor do I know how to divide by 8 properly, does anyone have any ideas on this?