(SRCTools Version 3.1.1) HexLoc DecLoc MachWord Label Instruction Comment ; ; CPE 221 Assembly Example ; ; This program adds a scalar value to all the elements in one ; array and stores that in another array. ; ; ; .org 200 000000c8 0000000200 0000000a size: .dc 10 000000cc 0000000204 00000005 a: .dc 5 000000d0 0000000208 00000005 x: .dc 5, 3, -1, 2, 4, 37, -100, 13, -5, 0 000000d4 0000000212 00000003 000000d8 0000000216 ffffffff 000000dc 0000000220 00000002 000000e0 0000000224 00000004 000000e4 0000000228 00000025 000000e8 0000000232 ffffff9c 000000ec 0000000236 0000000d 000000f0 0000000240 fffffffb 000000f4 0000000244 00000000 000000f8 0000000248 y: .dw 10 orig: .org 1000 000003e8 0000001000 37800040 lar r30, done 000003ec 0000001004 37400014 lar r29, loop 000003f0 0000001008 32bffcdc lar r10, x ; pointer to first element of x 000003f4 0000001012 32fffd00 lar r11, y ; pointer to first element of y 000003f8 0000001016 284000c8 la r1, size ; holds size of arrays 000003fc 0000001020 09000000 ld r4, 0 ; i = 0 00000400 0000001024 088000cc ld r2, a ; load a into r2 00000404 0000001028 71481000 loop: sub r5, r4, r1 ; Check to see whether index < size. 00000408 0000001032 403c5004 brpl r30, r5 ; If not, done. 0000040c 0000001036 e1880002 shl r6, r4, 2 ; Multiply index by 4 to access entry ; in array by byte address. 00000410 0000001040 60cca000 add r3, r6, r10 ; Add index to base pointer of x. 00000414 0000001044 620cb000 add r8, r6, r11 ; Add index to base pointer of y. 00000418 0000001048 09c60000 ld r7, 0(r3) ; Load array[i] into r7. 0000041c 0000001052 61ce2000 add r7, r7, r2 ; Add a to x[i] 00000420 0000001056 19d00000 st r7, 0(r8) ; Store result in y. 00000424 0000001060 69080001 addi r4, r4, 1 ; i++ 00000428 0000001064 403a0001 br r29 0000042c 0000001068 f8000000 done: stop --- Symbol Table --- x: 208 done: 1068 loop: 1028 a: 204 size: 200 orig: 1000 y: 248