public static short computeALU(short input0, short input1, boolean zero0, boolean negate0,
                                   boolean zero1, boolean negate1, boolean ADDorAND,
                                   boolean negateOutput) {
        short result;

        if (zero0)
            input0 = 0;
        if (zero1)
            input1 = 0;
        if (negate0)
            input0 = (short)(~input0);
        if (negate1)
            input1 = (short)(~input1);
        if (ADDorAND)
            result = (short)(input0 + input1);
        else
            result = (short)(input0 & input1);
        if (negateOutput)
            result = (short)(~result);

        return result;
    }