SUBR: MOV R1, -(R6) MOV R2, -(R6) MOV R3, -(R6) CLR R0 ; sum MOV R6, R1 MOV #4, R2 ADD R2, R1 ; skip over three saved registers, ret addr MOV@ R1, R2 ; second parameter, now how many are left INC R1 MOV@ R1, R1 ; first parameter, now pointer to current array element ; post-tested loop ok because guaranteed n>0 LOOP: MOV (R1)+, R3 ADD R3, R0 BVS RETURN ; with overflow flag set DEC R2 TST R2 BGT LOOP ; at this point R2=0, thus V is not set RETURN: MOV (R6)+, R3 MOV (R6)+, R2 MOV (R6)+, R1 RTS ; on a PDP-11 we'd need a "SEV" in the case of overflow because the ; MOVs would clear V; but VELMA's MOV doesn't affect V