Header Value Looping 5

Flowchart a procedure to read a header value n to indicate how many more values will be processed. For each of these values, determine if it is between 90 and 100, inclusive. Count all the values which fall in that range and print that count.

Flowchart      RAMM Machine Language Program     RAMM Assembly Language Program
    

Flowchart:



RAMM Machine Language Program:

0000  00  K
0000  01  N
0000  02  CT
0000  03  X
0000  04  K0
0001  05  K1
0090  06  K90
0100  07  K100
5000  08  STRT  No operation
1204  09        Load (A-Reg) with (K0)
2000  10        Store (A-Reg) at K
6501  11        Read N
1204  12        Load (A-Reg) with (K0)
2002  13        Store (A-Reg) at CT
6503  14  LOOP  Read X
1203  15        Load (A-Reg) with (X)
1506  16        Subtract (K90) from (A-Reg)
3726  17        Jump if (A-Reg) is negative to INCK
1203  18        Load (A-Reg) with (X)
1507  19        Subtract (K100) from (A-Reg)
3723  20        Jump if (A-Reg) is negative to INCC
3623  21        Jump if (A-Reg) is zero to INCC
7526  22        Unconditional Jump to INCK
1202  23  INCC  Load (A-Reg) with (CT)
1405  24        Add (K1) to (A-Reg)
2002  25        Store (A-Reg) at CT
1200  26  INCK  Load (A-Reg) with (K)
1405  27        Add (K1) to (A-Reg)
2000  28        Store (A-Reg) at K
1200  29        Load (A-Reg) with (K)
1501  30        Subtract (N) from (A-Reg)
3714  31        Jump if (A-Reg) is negative to LOOP
6602  32        Print CT
0000  33        Halt
9908  34        End and begin program execution at STRT


RAMM Assembly Language Program:

K     BSS 0001    
N     BSS 0001
CT    BSS 0001
X     BSS 0001
K0    DEC 0000
K1    DEC 0001
K90   DEC 0090
K100  DEC 0100
STRT  NOP
      LDA K0
      STA K
      RDI N
      LDA K0
      STA CT
LOOP  RDI X
      LDA X
      ISB K90
      AMJ INCK
      LDA X
      ISB K100
      AMJ INCC
      AZJ INCC
      UNJ INCK
INCC  LDA CT
      IAD K1
      STA CT
INCK  LDA K
      IAD K1
      STA K
      LDA K
      ISB N
      AMJ LOOP
      PRI CT
      HLT
      END STRT