Simple Flowcharts 6

Draw a flowchart to input two values, a and b. Print them both. Compute and print the absolute value of their difference. Remember that the comparison property of real numbers states that only one of the following three statements is true: either a = b, a > b, or a < b.

Flowchart      RAMM Machine Language Program     RAMM Assembly Language Program
    

Flowchart:



RAMM Machine Language Program:

0000  00  A
0000  01  B
0000  02  D
5000  03  STRT  No operation
6500  04        Read A  
6501  05        Read B    
6600  06        Print A 
6601  07        Print B
1200  08        Load (A-Reg) with (A)
1501  09        Subtract (B) from (A-Reg) 
2002  10        Store (A-Reg) at D   
1202  11        Load (A-Reg) with (D)
3715  12        Jump if (A-Reg) is negative to NEWD 
6602  13  PRID  Print D      
7519  14        Unconditional Jump to EXIT 
1201  15  NEWD  Load (A-Reg) with (B)
1500  16        Subtract (A) from (A-Reg)
2002  17        Store (A-Reg) at D
7513  18        Unconditional Jump to PRID 
0000  19  EXIT  Halt
9903  20        End and begin program execution at STRT


RAMM Assembly Language Program:

A     BSS 0001
B     BSS 0001
D     BSS 0001
STRT  NOP
      RDI A
      RDI B
      PRI A
      PRI B
      LDA A
      ISB B
      STA D
      LDA D
      AMJ NEWD
PRID  PRI D
      UNJ EXIT
NEWD  LDA B
      ISB A
      STA D
      UNJ PRID
EXIT  HLT
      END STRT