summaryrefslogtreecommitdiff
path: root/source/components/disassembler
diff options
context:
space:
mode:
Diffstat (limited to 'source/components/disassembler')
-rw-r--r--source/components/disassembler/dmbuffer.c8
-rw-r--r--source/components/disassembler/dmcstyle.c89
-rw-r--r--source/components/disassembler/dmopcode.c6
3 files changed, 80 insertions, 23 deletions
diff --git a/source/components/disassembler/dmbuffer.c b/source/components/disassembler/dmbuffer.c
index 8cd06a4b9a64..2291bb2c8d22 100644
--- a/source/components/disassembler/dmbuffer.c
+++ b/source/components/disassembler/dmbuffer.c
@@ -205,7 +205,7 @@ AcpiDmDisasmByteList (
}
BufChar = ByteData[CurrentIndex];
- if (ACPI_IS_PRINT (BufChar))
+ if (isprint (BufChar))
{
AcpiOsPrintf ("%c", BufChar);
}
@@ -554,7 +554,7 @@ AcpiDmIsStringBuffer (
* they will be handled in the string output routine
*/
- if (!ACPI_IS_PRINT (ByteData[i]))
+ if (!isprint (ByteData[i]))
{
return (FALSE);
}
@@ -836,7 +836,7 @@ AcpiDmUnicode (
{
AcpiOsPrintf ("\\%c", OutputValue);
}
- else if (!ACPI_IS_PRINT (OutputValue))
+ else if (!isprint (OutputValue))
{
AcpiOsPrintf ("\\x%2.2X", OutputValue);
}
@@ -902,7 +902,7 @@ AcpiDmGetHardwareIdType (
for (i = 0; i < 3; i++)
{
if (!ACPI_IS_ASCII (Prefix[i]) ||
- !ACPI_IS_ALPHA (Prefix[i]))
+ !isalpha (Prefix[i]))
{
return;
}
diff --git a/source/components/disassembler/dmcstyle.c b/source/components/disassembler/dmcstyle.c
index 1f1381969f57..a6ec689e157e 100644
--- a/source/components/disassembler/dmcstyle.c
+++ b/source/components/disassembler/dmcstyle.c
@@ -337,23 +337,70 @@ AcpiDmCheckForSymbolicOpcode (
*/
AcpiDmPromoteTarget (Op, Target);
- /*
- * Check for possible conversion to a "Compound Assignment".
- *
- * Determine if either operand is the same as the target
- * and display compound assignment operator and other operand.
- */
- if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)) ||
- (AcpiDmIsTargetAnOperand (Target, Child2, TRUE)))
+ /* Check operands for conversion to a "Compound Assignment" */
+
+ switch (Op->Common.AmlOpcode)
{
- Target->Common.OperatorSymbol =
- AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode);
+ /* Commutative operators */
+
+ case AML_ADD_OP:
+ case AML_MULTIPLY_OP:
+ case AML_BIT_AND_OP:
+ case AML_BIT_OR_OP:
+ case AML_BIT_XOR_OP:
+ /*
+ * For the commutative operators, we can convert to a
+ * compound statement only if at least one (either) operand
+ * is the same as the target.
+ *
+ * Add (A, B, A) --> A += B
+ * Add (B, A, A) --> A += B
+ * Add (B, C, A) --> A = (B + C)
+ */
+ if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)) ||
+ (AcpiDmIsTargetAnOperand (Target, Child2, TRUE)))
+ {
+ Target->Common.OperatorSymbol =
+ AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode);
- /* Convert operator to compound assignment */
+ /* Convert operator to compound assignment */
- Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND;
- Child1->Common.OperatorSymbol = NULL;
- return (TRUE);
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND;
+ Child1->Common.OperatorSymbol = NULL;
+ return (TRUE);
+ }
+ break;
+
+ /* Non-commutative operators */
+
+ case AML_SUBTRACT_OP:
+ case AML_DIVIDE_OP:
+ case AML_MOD_OP:
+ case AML_SHIFT_LEFT_OP:
+ case AML_SHIFT_RIGHT_OP:
+ /*
+ * For the non-commutative operators, we can convert to a
+ * compound statement only if the target is the same as the
+ * first operand.
+ *
+ * Subtract (A, B, A) --> A -= B
+ * Subtract (B, A, A) --> A = (B - A)
+ */
+ if ((AcpiDmIsTargetAnOperand (Target, Child1, TRUE)))
+ {
+ Target->Common.OperatorSymbol =
+ AcpiDmGetCompoundSymbol (Op->Common.AmlOpcode);
+
+ /* Convert operator to compound assignment */
+
+ Op->Common.DisasmFlags |= ACPI_PARSEOP_COMPOUND;
+ Child1->Common.OperatorSymbol = NULL;
+ return (TRUE);
+ }
+ break;
+
+ default:
+ break;
}
/*
@@ -423,8 +470,12 @@ AcpiDmCheckForSymbolicOpcode (
* source so that the target is processed first.
*/
Target = Child1->Common.Next;
- AcpiDmPromoteTarget (Op, Target);
+ if (!Target)
+ {
+ return (FALSE);
+ }
+ AcpiDmPromoteTarget (Op, Target);
if (!Target->Common.OperatorSymbol)
{
Target->Common.OperatorSymbol = " = ";
@@ -674,7 +725,8 @@ AcpiDmPromoteTarget (
*
* DESCRIPTION: Determine if a Target Op is a placeholder Op or a real Target.
* In other words, determine if the optional target is used or
- * not.
+ * not. Note: If Target is NULL, something is seriously wrong,
+ * probably with the parse tree.
*
******************************************************************************/
@@ -683,6 +735,11 @@ AcpiDmIsValidTarget (
ACPI_PARSE_OBJECT *Target)
{
+ if (!Target)
+ {
+ return (FALSE);
+ }
+
if ((Target->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
(Target->Common.Value.Arg == NULL))
{
diff --git a/source/components/disassembler/dmopcode.c b/source/components/disassembler/dmopcode.c
index d8ab1d51c758..a312582e595e 100644
--- a/source/components/disassembler/dmopcode.c
+++ b/source/components/disassembler/dmopcode.c
@@ -269,10 +269,10 @@ AcpiDmPredefinedDescription (
* Note: NameString is guaranteed to be upper case here.
*/
LastCharIsDigit =
- (ACPI_IS_DIGIT (NameString[3])); /* d */
+ (isdigit (NameString[3])); /* d */
LastCharsAreHex =
- (ACPI_IS_XDIGIT (NameString[2]) && /* xx */
- ACPI_IS_XDIGIT (NameString[3]));
+ (isxdigit (NameString[2]) && /* xx */
+ isxdigit (NameString[3]));
switch (NameString[1])
{