Implementation (contd)
CLAC Clear Accumulator
STAC total Store value 0 to address total
STAC i Store value 0 to address i
Loop: LDAC i Load contents of address i into accumulator
INAC Add 1 to the accumulator
STAC i Store result from accumulator back to address i
MVAC Move result from accumulator into Register R
LDAC total Load Total into accumulator
ADD Add contents of Register R and accumulator
and store it in accumulator
STAC total Store Total back to address total
LDAC n Load n into accumulator
SUB Subtract R (R = i) from AC (AC = n)
JPNZ Loop If result is not zero then jump back to loop:
No comments:
Post a Comment