ldi r12, #0 r12 holds an msb mask ldiu r12, #%8000 ldi r8, #0 r8 - running negative sum ldi r9, #0 r9 - running positive sum ldi r7, #8 r7 - loop count limit-1 ldi r0, #0 r0 - used for constant 0 ldi r1, #1 r1 - used for constant 1 ldi r15, stack r15 - stack pointer ldi r2, #0 r2 - loop counter ldi r4, data r4 - pointer to the data lp add r3, r4, r2 add loop count to data pointer (byte) ldb r5, #0(r3) get the byte from the array st #0(r15), r5 save the byte on the stack (param) brl r14, elmnt branch to the subroutine add r2, r1, r2 increment the loop counter sub r6, r2, r7 see if the count has been reached brt r6, lp if not, go back (loop) stb #8(r4), r8 save the negative sum in memory stb #9(r4), r9 save the positive sum in memory halt stop the CPU, assert "cpu-halted" * pc #%100 elmnt ld r11, #0(r15) get the datum off of the stack sub r10, r11, r0 dummy; subtract 0 from the datum and r10, r10, r12 test the msb (negative datum?) brf r10, pos if not, go to positive # handler add r8, r8, r11 negative, so add to negative sum brf r0, ret skip to return pos add r9, r9, r11 positive, so add to positive sum ret bri r14 return from subroutine data dw #%f00238f9 data, first four bytes dw #%0ffde700 data, last four bytes *15, -3, -25, 0; 0ffde700 data, last four bytes *data: -16, 2, 56, -7; f00238f9 data, first four bytes results dw #%00ffeedd garbage; last two bytes --> 49 and cd stack dw #%ffffffff garbage; stack