package rebelsky.pal; /** * The PAL instruction to write an integer. * * @author Samuel A. Rebelsky * @version 1.1 of December 2002. */ public class IWrite implements Instruction { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The container to write. */ Variable value; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Create a new instruction to write a value. */ public IWrite(Variable value) { this.value = value; } // IWrite(Variable) // +---------+----------------------------------------------------------- // | Methods | // +---------+ /** * Execute the instruction on a machine. * * @exception Exception * If the memory location is invalid. */ public void execute(Computer hal) throws Exception { hal.out.println(value.iget(hal)); } // execute(Computer) /** Convert the instruction to a string (usually for printing). */ public String toString() { return " IWRITE " + value.toString(); } // toString() } // class IWrite