FreeBSD/sys/contrib/dev/acpica/compiler/dtexpress.c
/******************************************************************************
 *
 * FUNCTION:    DtDoOperator
 *
 * PARAMETERS:  LeftValue           - First 64-bit operand
 *              Operator            - Parse token for the operator (EXPOP_*)
 *              RightValue          - Second 64-bit operand
 *
 * RETURN:      64-bit result of the requested operation
 *
 * DESCRIPTION: Perform the various 64-bit integer math functions
 *
 *****************************************************************************/


64-bit result of the requested operation

Perform the various 64-bit integer math functions
64 - bit result of the requested operation Perform the various 64 - bit integer math functions
UINT64
DtDoOperator (
    UINT64                  LeftValue,
    UINT32                  Operator,
    UINT64                  RightValue)
{
    UINT64                  Result;
    switch (Operator)
    {
    case EXPOP_ONES_COMPLIMENT:
        Result = ~RightValue;
        break;
    case EXPOP_LOGICAL_NOT:
        Result = !RightValue;
        break;
    case EXPOP_MULTIPLY:
        Result = LeftValue * RightValue;
        break;
    case EXPOP_DIVIDE:
        if (!RightValue)
        {
            DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO,
                Gbl_CurrentField, NULL);
            return (0);
        }
        Result = LeftValue / RightValue;
        break;
    case EXPOP_MODULO:
        if (!RightValue)
        {
            DtError (ASL_ERROR, ASL_MSG_DIVIDE_BY_ZERO,
                Gbl_CurrentField, NULL);
            return (0);
        }
        Result = LeftValue % RightValue;
        break;
    case EXPOP_ADD:
        Result = LeftValue + RightValue;
        break;
    case EXPOP_SUBTRACT:
        Result = LeftValue - RightValue;
        break;
    case EXPOP_SHIFT_RIGHT:
        Result = LeftValue >> RightValue;
        break;
    case EXPOP_SHIFT_LEFT:
        Result = LeftValue << RightValue;
        break;
    case EXPOP_LESS:
        Result = LeftValue < RightValue;
        break;
    case EXPOP_GREATER:
        Result = LeftValue > RightValue;
        break;
    case EXPOP_LESS_EQUAL:
        Result = LeftValue <= RightValue;
        break;
    case EXPOP_GREATER_EQUAL:
        Result = LeftValue >= RightValue;
        break;
    case EXPOP_EQUAL:
        Result = LeftValue == RightValue;
        break;
    case EXPOP_NOT_EQUAL:
        Result = LeftValue != RightValue;
        break;
    case EXPOP_AND:
        Result = LeftValue & RightValue;
        break;
    case EXPOP_XOR:
        Result = LeftValue ^ RightValue;
        break;
    case EXPOP_OR:
        Result = LeftValue | RightValue;
        break;
    case EXPOP_LOGICAL_AND:
        Result = LeftValue && RightValue;
        break;
    case EXPOP_LOGICAL_OR:
        Result = LeftValue || RightValue;
        break;
   default:
        DtFatal (ASL_MSG_INVALID_EXPRESSION,
            Gbl_CurrentField, NULL);
        return (0);
    }
    DbgPrint (ASL_DEBUG_OUTPUT,
        "IntegerEval: (%8.8X%8.8X %s %8.8X%8.8X) = %8.8X%8.8X\n",
        ACPI_FORMAT_UINT64 (LeftValue),
        DtGetOpName (Operator),
        ACPI_FORMAT_UINT64 (RightValue),
        ACPI_FORMAT_UINT64 (Result));
    return (Result);
}
UINT64 DtDoOperator ( UINT64 LeftValue , UINT32 Operator , UINT64 RightValue ) { UINT64 Result ; switch ( Operator ) { case EXPOP_ONES_COMPLIMENT : Result = ~ RightValue ; break ; case EXPOP_LOGICAL_NOT : Result = ! RightValue ; break ; case EXPOP_MULTIPLY : Result = LeftValue * RightValue ; break ; case EXPOP_DIVIDE : if ( ! RightValue ) { DtError ( ASL_ERROR , ASL_MSG_DIVIDE_BY_ZERO , Gbl_CurrentField , NULL ) ; return ( 0 ) ; } Result = LeftValue / RightValue ; break ; case EXPOP_MODULO : if ( ! RightValue ) { DtError ( ASL_ERROR , ASL_MSG_DIVIDE_BY_ZERO , Gbl_CurrentField , NULL ) ; return ( 0 ) ; } Result = LeftValue % RightValue ; break ; case EXPOP_ADD : Result = LeftValue + RightValue ; break ; case EXPOP_SUBTRACT : Result = LeftValue - RightValue ; break ; case EXPOP_SHIFT_RIGHT : Result = LeftValue >> RightValue ; break ; case EXPOP_SHIFT_LEFT : Result = LeftValue << RightValue ; break ; case EXPOP_LESS : Result = LeftValue < RightValue ; break ; case EXPOP_GREATER : Result = LeftValue > RightValue ; break ; case EXPOP_LESS_EQUAL : Result = LeftValue <= RightValue ; break ; case EXPOP_GREATER_EQUAL : Result = LeftValue >= RightValue ; break ; case EXPOP_EQUAL : Result = LeftValue == RightValue ; break ; case EXPOP_NOT_EQUAL : Result = LeftValue != RightValue ; break ; case EXPOP_AND : Result = LeftValue & RightValue ; break ; case EXPOP_XOR : Result = LeftValue ^ RightValue ; break ; case EXPOP_OR : Result = LeftValue | RightValue ; break ; case EXPOP_LOGICAL_AND : Result = LeftValue && RightValue ; break ; case EXPOP_LOGICAL_OR : Result = LeftValue || RightValue ; break ; default : DtFatal ( ASL_MSG_INVALID_EXPRESSION , Gbl_CurrentField , NULL ) ; return ( 0 ) ; } DbgPrint ( ASL_DEBUG_OUTPUT , " \n " , ACPI_FORMAT_UINT64 ( LeftValue ) , DtGetOpName ( Operator ) , ACPI_FORMAT_UINT64 ( RightValue ) , ACPI_FORMAT_UINT64 ( Result ) ) ; return ( Result ) ; }
FUNCTION:    DtDoOperator
 PARAMETERS:  LeftValue           - First 64-bit operand
              Operator            - Parse token for the operator (EXPOP_*)
              RightValue          - Second 64-bit operand
FUNCTION : DtDoOperator PARAMETERS : LeftValue - First 64 - bit operand Operator - Parse token for the operator ( EXPOP_ * ) RightValue - Second 64 - bit operand
/* Perform the requested operation */ /* Unknown operator */