void InstructionToString(char* Buffer, Inst* Instruction)
{
    // Add the prefix if there was one
    if(Instruction->Prefix != PREFIX_NONE)
    {
        strcat(Buffer, PrefixToString(Instruction->Prefix));
        strcat(Buffer, " ");
    }

    // Append mnemonic
    strcat(Buffer, Instruction->Mnemonic);

    // Append all operands
    if(Instruction->OperandCount > 0)
    {
        strcat(Buffer, " ");

        for(int i = 0; i < Instruction->OperandCount; i++)
        {
            char op[XEDPARSE_MAXBUFSIZE];
            OperandToString(op, &Instruction->Operands[i]);

            strcat(Buffer, op);
            strcat(Buffer, ", ");
        }

        // Remove the final trailing comma
        *strrchr(Buffer, ',') = '\0';
    }
}
示例#2
0
文件: condeval.cpp 项目: garinh/cs
csString csConditionEvaluator::OperationToString (const CondOperation& operation)
{
  const char* opStr;
  switch (operation.operation)
  {
    case opAnd:       opStr = "&&"; break;
    case opOr:        opStr = "||"; break;
    case opEqual:     opStr = "=="; break;
    case opNEqual:    opStr = "!="; break;
    case opLesser:    opStr = "<"; break;
    case opLesserEq:  opStr = "<="; break;
    default:
      return (const char*)0;
  }
  
  csString ret;
  ret.Format ("%s %s %s",
    OperandToString (operation.left).GetData(),
    opStr,
    OperandToString (operation.right).GetData());
  return ret;
}