Variable var = (Variable) operand2;
Variable var = (Variable) refs[1];
    public void generateCodeForBinary(CodeGenerator cg) {        cg.checkLabel(getAddress());        int op1Mode = operand1.getAddressingMode();        int op2Mode = operand2.getAddressingMode();        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 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 = (op1Mode << 8) | op2Mode;        switch (aMode) {            case MODE_CC:                cg.generateCodeFor(this, c2, condition, c3);                break;            case MODE_CR:                if (commutative && !cg.supports3AddrOps()) {                    cg.generateCodeFor(this, reg3, condition, c2);                } else {                    cg.generateCodeFor(this, c2, condition, reg3);                }                break;            case MODE_CS:                cg.generateCodeFor(this, c2, condition, disp3);                break;            case MODE_RC:                cg.generateCodeFor(this, reg2, condition, c3);                break;            case MODE_RR:                if (commutative && !cg.supports3AddrOps()) {                    cg.generateCodeFor(this, reg3, condition, reg2);                } else {                    cg.generateCodeFor(this, reg2, condition, reg3);                }                break;            case MODE_RS:                cg.generateCodeFor(this, reg2, condition, disp3);                break;            case MODE_SC:                cg.generateCodeFor(this, disp2, condition, c3);                break;            case MODE_SR:                if (commutative && !cg.supports3AddrOps()) {                    cg.generateCodeFor(this, reg3, condition, disp2);                } else {                    cg.generateCodeFor(this, disp2, condition, reg3);                }                break;            case MODE_SS:                cg.generateCodeFor(this, disp2, condition, disp3);                break;            default:                throw new IllegalArgumentException("Undefined addressing mode: " + aMode);        }    }