//
// Name
//
//   intToAscii.jas
//
// Description
//
//   This program converts an integer (word) to a series of ascii characters
//
// Author
//
//   Bruce D'Ambrosio
//
// Modification History
//
// Notes
//

.constant
objref  0xCAFE  // may be any value.  Needed by invokevirtual.
my_max  100
.end-constant

.main
.var
N
R
.end-var

	BIPUSH 0x7f    // integer to be translated to ascii
	ISTORE N

        BIPUSH 0x02    // R=0
        ISTORE R

L1:     ILOAD R        // if (R == 0) GOTO L4
        BIPUSH 0x00
        ISUB
        IFLT L4
        
        ILOAD R        // R = R-1
        BIPUSH 0x01
        ISUB
        ISTORE R
        
        BIPUSH 0x41    // Print A
        OUT

        GOTO L1        // Loop till done

L4:     BIPUSH 0x20    // Print "DONE"
        OUT
        BIPUSH 0x44    
	OUT
	BIPUSH 0x4F
        OUT
        BIPUSH 0x4E
        OUT
        BIPUSH 0x45
        OUT

	HALT           // halt

.end-main