import java.io.PrintWriter; import Instruction; /** * The standard "Add" instruction for AAAL, the amazingly abstract * assembly language. * * @author Samuel A. Rebelsky * @version 1.0 of April 2001 */ public class Add implements Instruction { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The first value being added. */ protected Location left; /** The second value being added. */ protected Location right; /** The destination of the add command. Where data goes to. */ protected Location result; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Build a new add with specified arguments and result. */ public Add(Location left, Location right, Location result) { this.left = left; this.right = right; this.result = result; } // Add(Location, Location, Location); // +---------------------+----------------------------------------------- // | Instruction Methods | // +---------------------+ /** * Print the instruction. */ public void print(PrintWriter out) { out.print(" ADD "); this.left.print(out); out.print(" + "); this.right.print(out); out.print(" -> "); this.result.print(out); out.println(); } // print(PrintWriter) } // class Add