Instruction - This file is part of the...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * * * This file is part of the EduMIPS64 project, and is released under the GNU * General Public License. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package; import edumips64.core.*; import edumips64.utils.*; import java.util.*; import java.util.logging.Logger; import java.lang.Enum.*; /**Abstract class: it provides all methods and attributes for each instruction type * * @author Trubia Massimo, Russo Daniele */ public abstract class Instruction { protected BitSet32 repr; protected List<Integer> params; protected int paramCount; protected String syntax; protected String name; protected String comment; protected static Memory memory=Memory.getInstance(); protected Register[] TR; //is not static because each instruction has got its own registers protected String fullname; protected static boolean enableForwarding=(Boolean)Config.get("forwarding"); protected String label; protected static final Logger logger = Logger.getLogger(Instruction.class.getName()); /** Creates a new instance of Instruction */ public Instruction() { params=new LinkedList<Integer>(); TR=new Register[5]; repr=new BitSet32(); repr.reset(false); syntax=new String(); //initialization of temporary registers for(int i=0;i<TR.length;i++) { TR[i]=new Register(); } }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
/** <pre> * Returns a BitSet32 holding the binary representation of the Instruction * @return the Bitset32 representing the instruction * </pre> * */ public BitSet32 getRepr() { return repr; } /** * Creates a new instance of an Instruction's subclass @param name string value to pass in order to instanciate an instruction object @return the instruction object * */ public static Instruction buildInstruction(String name){ Instruction returnedObject=null; for (InstructionEnumerator op : InstructionEnumerator.values()) { if ( { returnedObject=op.getObject(); return returnedObject; } } return returnedObject; } public enum InstructionEnumerator { //ALU R-Type 32-bits ADD { Instruction getObject() { ADD newObject=new ADD();return newObject; } }, ADDU { Instruction getObject() { ADDU newObject=new ADDU(); return newObject; } }, SUB { Instruction getObject() { SUB newObject=new SUB();return newObject;}}, SUBU { Instruction getObject() { SUBU newObject=new SUBU(); return newObject; } }, DIV { Instruction getObject() { DIV
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/13/2011 for the course ECSE 111 taught by Professor Donnboo during the Fall '11 term at McGill.

Page1 / 8

Instruction - This file is part of the...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online