Index Looping 2

Flowchart a procedure to read 100 values, print only the positive values and then stop.

Flowchart      RAMM Machine Language Program     RAMM Assembly Language Program
    

Flowchart:



RAMM Machine Language Program:

0000 00 Decimal constant of 0, I0
0001 01 Decimal constant of 1, I1
0100 02 Decimal constant of 100, I100
0000 03 Storage for K
0000 04 Storage for X
5000 05 STRT  no operation
1200 06       (A-reg) <- (I0)
2003 07       (K) <- (A-reg)
1203 08 LOOP  (A-reg) <- K
1502 09       (A-reg) <- (A-reg) - (I100)
3712 10       If (A-reg) < 0, then jump to CONT
0000 11       Halt
6504 12 CONT  Read X
1204 13       (A-reg) <- (X)
3717 14       If (A-reg) < 0, then jump to INCK
3617 15       If (A-reg) < 0, then jump to INCK
6604 16       Print X
1203 17 INCK  (A-reg) <- K
1401 18       (A-reg) <- (A-reg) + (I1)
2003 19       (K) <- (A-reg)
7508 20       Unconditional jump to LOOP
9905 21       End; program execution begins at STRT


RAMM Assembly Language Program:

I0    DEC 0000
I1    DEC 0001
I100  DEC 0100
K     BSS 0001
X     BSS 0001
STRT  NOP
      LDA I0
      STA K
LOOP  LDA K
      ISB I100
      AMJ CONT
      HLT
CONT  RDI X
      LDA X
      AMJ INCK
      AZJ INCK
      PRI X
INCK  LDA K
      IAD I1
      STA K
      UNJ LOOP
      END STRT