Index Looping 3

Flowchart a procedure to read a value h (number of hours worked) and a value r (hourly rate of pay), compute p (gross pay), and print hours, rate, and gross pay for each of 20 employees.

Flowchart      RAMM Machine Language Program     RAMM Assembly Language Program
    

Flowchart:



RAMM Machine Language Program:

0000  00  C
0000  01  H
0000  02  R                                                  
0000  03  P
0001  04  K1
0020  05  K20
5000  06  STRT  NOP
1204  07        Load (A-Reg) with (K1)
2000  08        Store (A-Reg) at C
1200  09  LOOP  Load (A-Reg) with (C)
1505  10        Subtract (K20) from (A-Reg)
3714  11        Jump if (A-Reg) is negative to RDIH
3614  12        Jump if (A-Reg) is zero to RDIH
7526  13        Unconditional Jump to EXIT
6501  14  RDIH  Read H
6502  15        Read R
1201  16        Load (A-Reg) with (H)
2402  17        Multiply (A-Reg) by (R)
2003  18        Store (A-Reg) at P
6601  19        Print H
6602  20        Print R
6603  21        Print P
1200  22        Load (A-Reg) with (C)
1404  23        Add (K1) to (A-Reg)
2000  24        Store (A-Reg) at C
7509  25        Unconditional Jump to LOOP
0000  26  EXIT  Halt
9906  27        End and begin program execution at STRT


RAMM Assembly Language Program:

C     BSS 0001  
H     BSS 0001
R     BSS 0001
P     BSS 0001
K1    DEC 0001
K20   DEC 0020
STRT  NOP
      LDA K1
      STA C
LOOP  LDA C
      ISB K20
      AMJ RDIH
      AZJ RDIH
      UNJ EXIT
RDIH  RDI H
      RDI R
      LDA H
      IMU R
      STA P
      PRI H
      PRI R
      PRI P
      LDA C
      IAD K1
      STA C
      UNJ LOOP
EXIT  HLT
      END STRT