Simple Flowcharts 5

Determine and print the absolute value of a. (Note: the absolute value of 3=3, the absolute value of -3=3, and the absolute value of 0=0.)

Flowchart      RAMM Machine Language Program     RAMM Assembly Language Program
    

Flowchart:



RAMM Machine Language Program:

-001 00 Decimal constant of -1     
0000 01 Storage for A
5000 02 STRT  No operation
6501 03       Read (A)        
1201 04       (A-reg) <- (A)        
3709 05       If (A-reg) < 0, then jump to ANEG
5000 06 PRNT  No operation
6601 07       Print (A)
0000 08       Halt  
5000 09 ANEG  No operation
2400 10       (A-reg) <- (A-reg) * (-1)
2001 11       (A) <- (A-reg)
7506 12       Unconditional jump to PRNT
9902 13       End; begin program execution at STRT


RAMM Assembly Language Program:

M1    DEC -001
A     BSS 0001
STRT  NOP
      RDI A
      LDA A
      AMJ ANEG
PRNT  NOP
      PRI A
      HLT
ANEG  NOP
      IMU M1
      STA A
      UNJ PRNT
      END STRT