// This code uses a loop to generate values for a small three element // array stored at location 80; it accesses the array by using an offset // from R4, which is initialized to 0. // It then adds the three elements together, this time by setting R4 // to the address of the middle element (84), and using load instructions // that offset (both positively and negatively) from this value. The final // answer (ie., the sum) is stored in R7, and in memory location 92 (0x5c). 00000000 20010003 ADDI R1, R0, 3 // initialize loop counter 00000004 20020014 ADDI R2, R0, 20 // r2 is used to generate values 00000008 00002020 ADD R4, R0, R0 // r4 = array offset, initially 0 0000000C 34430009 ORI R3, R2, 9 // create a value 00000010 AC830050 SW R3, 80(R4) // store value in memory 00000014 2042000A ADDI R2, R2, 10 // get ready for next value 00000018 2021FFFF ADDI R1, R1, -1 // decrement loop counter 0000001C 20840004 ADDI R4, R4, 4 // increment array offset 00000020 1401FFFA BNE R1, R0, 0xc // branch back to "ori" instruction 00000024 20040054 ADDI R4, R0, 84 // reinitialize array offset, this time // to middle element 00000028 8C85FFFC LW R5, -4(R4) // get first array element 0000002C 8C860000 LW R6, 0(R4) // get second array element 00000030 00C53820 ADD R7, R6, R5 // add first 2 elements 00000034 8C880004 LW R8, 4(R4) // get third element 00000038 00E83820 ADD R7, R7, R8 // add to sum 0000003C AC870008 SW R7, 8(R4) // store result after array (mwmory // location 92, or 0x5c) 00000040 08000010 J 0x40 // jump to self