package rebelsky.pal; /** * The basic floating poitn multiplication instruction in PAL. * * @author Samuel A. Rebelsky * @version 1.0 of December 2002. */ public class FMult implements Instruction { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The left operand of the operation. */ Variable left; /** The right operand of the operation. */ Variable right; /** The destination of the operation. */ Variable destination; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Create a new instruction to multiply two values and store the * result in destination. */ public FMult(Variable left, Variable right, Variable destination) { this.left = left; this.right = right; this.destination = destination; } // FMult(Variable,Variable,Variable) // +---------+----------------------------------------------------------- // | Methods | // +---------+ /** * Execute the instruction on a machine. * * @exception Exception * If one of the memory locations is invalid. * If the destination is a constant or label. */ public void execute(Computer hal) throws Exception { destination.fset(hal, (left.fget(hal) * right.fget(hal))); } // execute(Computer) /** Convert the instruction to a string (usually for printing). */ public String toString() { return " FMULT " + left.toString() + ", " + right.toString() + " -> " + destination.toString(); } // toString() } // class FMult