; Author: Andres Calderon Jaramillo ; Description: Solves the problem in slide #28 in Lecture13(C5) ; (computes the sum of the first 12 integers starting at 1) ; .ORIG x3000 ; Program starts at x3000 AND R3, R3, #0 ; Initialize R3 to 0 (will contain the sum) AND R2, R2, #0 ; Initialize R2 to 12 (will act as loop counter) ADD R2, R2, #12 ; Loop BRz Exit ; Exit the loop if R2 is 0 ADD R3, R3, R2 ; R3 = R3 + R2 ADD R2, R2, #-1 ; Decrement R2 (modifies condition code) BR Loop ; Go to the beginning of the loop Exit HALT ; End the program (R3 now contains the sum) .END