Index Looping 6

Read a value a. Flowchart a procedure to read in 25 data values, to count the number of negative (less than zero) values which were read in, to print this count and stop.

Flowchart      RAMM Machine Language Program     RAMM Assembly Language Program
    

Flowchart:



RAMM Machine Language Program:

0000 00 Integer constant of 0, I0
0001 01 Integer constant of 1, I1
0025 02 Integer constant of 25, I25
???? 03 Storage location for C
???? 04 Storage location for N
???? 05 Storage location for X
5000 06 STRT  no operation
1200 07       (A-reg) <- (I0)
2004 08       (N) <- (A-reg)
2003 09       (C) <- (A-reg)
1203 10 LOOP  (A-reg) <- (C)
1502 11       (A-reg) <- (A-reg) - (I25)
3715 12       If (A-reg) < 0, then jump to READ
6604 13       Print N
0000 14       Halt
6505 15 READ  Read X
1205 16       (A-reg) <- (X)
3722 17       If (A-reg) < 0, then jump to INCN
1203 18 INCC  (A-reg) <- (C)
1401 19       (A-reg) <- (A-reg) + (I1)
2003 20       (C) <- (A-reg)
7510 21       Unconditionally jump to LOOP
1204 22 INCN  (A-reg) <- (N)
1401 23       (A-reg) <- (A-reg) + (I1)
2004 24       (N) <- (A-reg)
7518 25       Unconditionally jump to INCC
9906 26       End; program execution begins at STRT


RAMM Assembly Language Program:

I0    DEC 0000
I1    DEC 0001
I25   DEC 0025
C     BSS 0001
N     BSS 0001
X     BSS 0001
STRT  NOP
      LDA I0
      STA N
      STA C
LOOP  LDA C
      ISB I25
      AMJ READ
      PRI N
      HLT
READ  RDI X
      LDA X
      AMJ INCN
INCC  LDA C
      IAD I1
      STA C
      UNJ LOOP
INCN  LDA N
      IAD I1
      STA N
      UNJ INCC
      END STRT