ROUTINE: | MOV R1, -(R6) |
MOV R2, -(R6) | |
CLR R0 ; sum | |
MOV 10(R6), R1 ; pointer to current array element | |
MOV 6(R6), R2 ; how many are left | |
; post-tested loop ok because guaranteed n>0 | |
LOOP: | ADD (R1)+, R0 |
BVS OVERFLOW | |
DEC R2 | |
BGT LOOP | |
MOV (R6)+, R2 | |
MOV (R6)+, R1 | |
RTS R7 ; V clear by MOV | |
OVERFLOW: | MOV (R6)+, R2 |
MOV (R6)+, R1 | |
SEV ; the MOVs cleared V | |
RTS R7 |