Index Looping 4

Flowchart a procedure to read in two values, a and b. Determine which value is larger (assume they are unequal) and print it. Repeat this for 5 sets of values and then 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
0005 02 Integer constant of 5, I5
0000 03 Storage for A
0000 04 Storage for B
0000 05 Storage for D
0000 06 Storage for K
5000 07 STRT  no operation
1200 08       (A-reg) <- (I0)
2006 09       (K) <- (A-reg)
6503 10 LOOP  Read A
6504 11       Read B
1203 12       (A-reg) <- (A)
1504 13       (A-reg) <- (A-reg) - (B)
2005 14       (D) <- (A-reg)
3719 15       If (A-reg) < 0, then jump to PRIB
3619 16       If (A-reg) = 0, then jump to PRIB
6603 17       Print A
7520 18       Unconditional jump to INCK
6604 19 PRIB  Print B
1206 20 INCK  (A-reg) <- (K)
1401 21       (A-reg) <- (A-reg) + (I1)
2006 22       (K) <- (A-reg)
1502 23       (A-reg) <- (A-reg) - (I5)
3710 24       If (A-reg) < 0, then jump to LOOP
0000 25       Halt
9907 26       End; start program execution at STRT



RAMM Assembly Language Program:

I0    DEC 0000
I1    DEC 0001
I5    DEC 0005
A     BSS 0001
B     BSS 0001
D     BSS 0001
K     BSS 0001
STRT  NOP
      LDA I0
      STA K
LOOP  RDI A
      RDI B
      LDA A
      ISB B
      STA D
      AMJ PRIB
      AZJ PRIB
      PRI A
      UNJ INCK
PRIB  PRI B
INCK  LDA K
      IAD I1
      STA K
      ISB I5
      AMJ LOOP
      HLT
      END STRT