ISA cont. #
Accumulator ISA cont. #
.code ; start of program code
LD 0 ; initialize ACC <- 0
ST (sum) ; M[sum] <- ACC
ST (i) ; M[i] <- ACC
L1:
CMP 7 ; i > 7?
JGT L2 ; jump to L2 if greater flag is on
MVX ; get next index, X <- ACC
LD X(array) ; get next array element, ACC <- M[array + x]
ADD (sum) ; add i to running sum, ACC <- ACC + M[sum]
ST (sum) ; store running sum, M[sum] <- ACC
LD (i) ; get i, ACC <- M[i]
ADD 1 ; i++
ST (i) ; M[i] <- ACC
JMP L1
L2: