Variable var = (Variable) operand2;
Variable var = (Variable) refs[1];
	public void generateCode(CodeGenerator cg) {        cg.checkLabel(getAddress());		Variable lhs = getLHS();		int lhsMode = lhs.getAddressingMode();		int op1Mode = operand1.getAddressingMode();		int op2Mode = operand2.getAddressingMode();		Object reg1 = null;		if (lhsMode == Operand.MODE_REGISTER) {			RegisterLocation regLoc = (RegisterLocation) lhs.getLocation();			reg1 = regLoc.getRegister();		}		Object reg2 = null;		if (op1Mode == Operand.MODE_REGISTER) {			Variable var = (Variable) operand1;			RegisterLocation regLoc = (RegisterLocation) var.getLocation();			reg2 = regLoc.getRegister();		}		Object reg3 = null;		if (op2Mode == Operand.MODE_REGISTER) {			Variable var = (Variable) operand2;			RegisterLocation regLoc = (RegisterLocation) var.getLocation();			reg3 = regLoc.getRegister();		}		int disp1 = 0;		if (lhsMode == Operand.MODE_STACK) {			StackLocation stackLoc = (StackLocation) lhs.getLocation();			disp1 = stackLoc.getDisplacement();		}		int disp2 = 0;		if (op1Mode == Operand.MODE_STACK) {			Variable var = (Variable) operand1;			StackLocation stackLoc = (StackLocation) var.getLocation();			disp2 = stackLoc.getDisplacement();		}		int disp3 = 0;		if (op2Mode == Operand.MODE_STACK) {			Variable var = (Variable) operand2;			StackLocation stackLoc = (StackLocation) var.getLocation();			disp3 = stackLoc.getDisplacement();		}		Constant c2 = null;		if (op1Mode == Operand.MODE_CONSTANT) {			c2 = (Constant) operand1;		}		Constant c3 = null;		if (op2Mode == Operand.MODE_CONSTANT) {			c3 = (Constant) operand2;		}		int aMode = (lhsMode << 16) | (op1Mode << 8) | op2Mode;		switch (aMode) {			case MODE_RCC:				cg.generateBinaryOP(reg1, c2, operation, c3);				break;			case MODE_RCR:				if (reg1 == reg3 && commutative && !cg.supports3AddrOps()) {					cg.generateBinaryOP(reg1, reg3, operation, c2);				} else {					cg.generateBinaryOP(reg1, c2, operation, reg3);				}				break;			case MODE_RCS:				cg.generateBinaryOP(reg1, c2, operation, disp3);				break;			case MODE_RRC:				cg.generateBinaryOP(reg1, reg2, operation, c3);				break;			case MODE_RRR:				if (reg1 == reg3 && commutative && !cg.supports3AddrOps()) {					cg.generateBinaryOP(reg1, reg3, operation, reg2);				} else {					cg.generateBinaryOP(reg1, reg2, operation, reg3);				}				break;			case MODE_RRS:				cg.generateBinaryOP(reg1, reg2, operation, disp3);				break;			case MODE_RSC:				cg.generateBinaryOP(reg1, disp2, operation, c3);				break;			case MODE_RSR:				if (reg1 == reg3 && commutative && !cg.supports3AddrOps()) {					cg.generateBinaryOP(reg1, reg3, operation, disp2);				} else {					cg.generateBinaryOP(reg1, disp2, operation, reg3);				}				break;			case MODE_RSS:				cg.generateBinaryOP(reg1, disp2, operation, disp3);				break;			case MODE_SCC:				cg.generateBinaryOP(disp1, c2, operation, c3);				break;			case MODE_SCR:				cg.generateBinaryOP(disp1, c2, operation, reg3);				break;			case MODE_SCS:				if (disp1 == disp3 && commutative && !cg.supports3AddrOps()) {					cg.generateBinaryOP(disp1, disp3, operation, c2);				} else {					cg.generateBinaryOP(disp1, c2, operation, disp3);				}				break;			case MODE_SRC:				cg.generateBinaryOP(disp1, reg2, operation, c3);				break;			case MODE_SRR:				cg.generateBinaryOP(disp1, reg2, operation, reg3);				break;			case MODE_SRS:				if (disp1 == disp3 && commutative && !cg.supports3AddrOps()) {					cg.generateBinaryOP(disp1, disp3, operation, reg2);				} else {					cg.generateBinaryOP(disp1, reg2, operation, disp3);				}				break;			case MODE_SSC:				cg.generateBinaryOP(disp1, disp2, operation, c3);				break;			case MODE_SSR:				cg.generateBinaryOP(disp1, disp2, operation, reg3);				break;			case MODE_SSS:				if (disp1 == disp3 && commutative && !cg.supports3AddrOps()) {					cg.generateBinaryOP(disp1, disp3, operation, disp2);				} else {					cg.generateBinaryOP(disp1, disp2, operation, disp3);				}				break;			default:				throw new IllegalArgumentException("Undefined addressing mode: " + aMode);		}	}