(SRCTools Version 3.1.1) HexLoc DecLoc MachWord Label Instruction Comment ; ; CPE 221 Assembly Example ; ; This program finds the maximum value in an array ; .org 200 000000c8 0000000200 0000000a size: .dc 10 000000cc 0000000204 neg_count: .dw 1 000000d0 0000000208 pos_count: .dw 1 000000d4 0000000212 00000064 nums: .dc 100, 3, -1, 2, 4, 37, -100, 13, -5, 0 000000d8 0000000216 00000003 000000dc 0000000220 ffffffff 000000e0 0000000224 00000002 000000e4 0000000228 00000004 000000e8 0000000232 00000025 000000ec 0000000236 ffffff9c 000000f0 0000000240 0000000d 000000f4 0000000244 fffffffb 000000f8 0000000248 00000000 orig: .org 1000 000003e8 0000001000 32bffce8 lar r10, nums ; pointer to first element of array 000003ec 0000001004 084000c8 ld r1, size ; holds size of array 000003f0 0000001008 28800000 la r2, 0 ; i = 0 000003f4 0000001012 28c00000 la r3, 0 ; neg_count = 0 000003f8 0000001016 29000000 la r4, 0 ; pos_count = 0 000003fc 0000001020 37c00030 lar r31, done 00000400 0000001024 37800004 lar r30, loop 00000404 0000001028 37400020 lar r29, negative 00000408 0000001032 71441000 loop: sub r5, r2, r1 ; Check to see whether index < size. 0000040c 0000001036 403c5004 brpl r30, r5 ; If not, done. 00000410 0000001040 e1420002 shl r5, r1, 2 ; Multiply index by 4 to access entry ; in array by byte address. 00000414 0000001044 614aa000 add r5, r5, r10 ; Add index to base array pointer. 00000418 0000001048 094a0000 ld r5, 0(r5) ; Load array[index] into r7. 0000041c 0000001052 403a5005 brmi r29, r5 00000420 0000001056 69080001 addi r4, r4, 1 ; pos_count++ 00000424 0000001060 403c0001 br r30 00000428 0000001064 68c60001 negative: addi r3, r3, 1 ; neg_count++ 0000042c 0000001068 403c0001 br r30 00000430 0000001072 18c000cc done: st r3, neg_count 00000434 0000001076 190000d0 st r4, pos_count 00000438 0000001080 f8000000 stop --- Symbol Table --- done: 1072 loop: 1032 negative: 1064 neg_count: 204 size: 200 nums: 212 pos_count: 208 orig: 1000