Trailer Value Looping 3

Read records from a file, one value per record. Sum all these values (cumulative sum) until a trailer of -999 is encountered. Then print the sum and stop. (Note that -999 is not included in the sum.)

Flowchart      RAMM Machine Language Program     RAMM Assembly Language Program
    

Flowchart:



RAMM Machine Language Program:

0000  00  S
0000  01  X
0000  02  K0
-999  03  TV
5000  04  STRT  No operation
1202  05        Load (A-Reg) with (K0)
2000  06        Store (A-Reg) at S
6501  07  LOOP  Read X
1201  08        Load (A-Reg) with (X)
1503  09        Subtract (TV) from (A-Reg)
3615  10        Jump if (A-Reg) is zero to EXIT
1200  11        Load (A-Reg) with (S)
1401  12        Add (X) to (A-Reg)
2000  13        Store (A-Reg) at S
7507  14        Unconditional Jump to LOOP
6600  15  EXIT  Print S
0000  16        Halt
9904  17        End and begin program execution at STRT


RAMM Assembly Language Program:

S     BSS 0001   
X     BSS 0001
K0    DEC 0000
TV    DEC -999
STRT  NOP
      LDA K0
      STA S
LOOP  RDI X
      LDA X
      ISB TV
      AZJ EXIT
      LDA S
      IAD X
      STA S
      UNJ LOOP
EXIT  PRI S
      HLT
      END STRT