0

Here is my instructions:

Set a “Result” register value equal to the result of the behavior described here:

index0 = a10[0];

index1 = a10[1];

Result = Result + a10[ index0 ] + a10[ index1 ] * a10[ index1 ];

Here is what I have so far

    MOV R11 #11;
loop
    SUBS R11 #1;        counts down from 10, to run the loop 10 times. Did counting down because its more efficient.
    MOV R1, [R2, #4];   index 1
    MOV R0, R2;         index 0
    MOV R5, [R1];       R5 = a10[1]
    
    MOV R6, [R0];       R6 = a10[0]
    
    ADD R3, R3, R5;     Result = Result + a10[a10[0]]
    MUL R4, R1, R6;     R4 = a10[a10[1]] * a10[a10[1]]
    ADD R7, R3, R4;     R7 = Result + a10[a10[0]] + a10[a10[1]] * a10[a10[1]]
    
        B   loop
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • I assume this is ARM, one of the architectures that Keil's toolchain can target... Except it doesn't use `mov` to load or store, it uses `ldr` / `str`. Also, it has indexed addressing modes, so you can probably just increment one index in the loop and use it with both pointers separately. – Peter Cordes Sep 27 '22 at 06:58

0 Answers0