You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
949 B

package generic;
public class Operand {
public enum OperandType {Register, Immediate, Label};
OperandType operandType;
int value;
String labelValue; //only applicable for Label type;
//Note that Label type is only applicable for functional emulation of assembly file
public OperandType getOperandType() {
return operandType;
}
public void setOperandType(OperandType operandType) {
this.operandType = operandType;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public String getLabelValue() {
return labelValue;
}
public void setLabelValue(String labelValue) {
this.labelValue = labelValue;
}
public String toString()
{
if(operandType == OperandType.Register || operandType == OperandType.Immediate)
{
return "[" + operandType.toString() + ":" + value + "]";
}
else
{
return "[" + operandType.toString() + ":" + labelValue + "]";
}
}
}