示例#1
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder(this.opcode.ToString() + "");

            if (size != 1)
            {
                if (operand1.OperandAddressingMode == AddressingMode.IMMEDIATE_32)
                {
                    sb.AppendFormat("\t0x{0}", ((uint)this.operand1.Value).ToString("x8"));
                }
                else if (operand1.OperandAddressingMode == AddressingMode.DIRECT_REGISTER)
                {
                    sb.AppendFormat("\t%{0}", operand1.Value.ToString());
                }
                else if (operand1.Value is IndirectOffset)
                {
                    IndirectOffset offset = operand1.Value as IndirectOffset;
                    if (offset.Offset == 0)
                    {
                        sb.AppendFormat("\t@{0}", offset.Register.ToString());
                    }
                    else
                    {
                        sb.AppendFormat("\t@{0}:0x{1:x}", offset.Register.ToString(), offset.Offset);
                    }
                }
                if (operand2.OperandAddressingMode != AddressingMode.NONE)
                {
                    if (operand1.OperandAddressingMode != AddressingMode.CONDITION_CODE)
                    {
                        sb.Append(",\t");
                    }
                    else
                    {
                        sb.Append(new string[] { "", " S", " Z", " C" }[(byte)operand1.Value]);
                    }
                    if (operand2.OperandAddressingMode == AddressingMode.IMMEDIATE_32)
                    {
                        sb.AppendFormat("\t0x{0}", ((uint)this.operand2.Value).ToString("x8"));
                    }
                    else if (operand2.OperandAddressingMode == AddressingMode.DIRECT_REGISTER)
                    {
                        sb.AppendFormat("\t%{0}", operand2.Value.ToString());
                    }
                    else if (operand2.Value is IndirectOffset)
                    {
                        IndirectOffset offset = operand2.Value as IndirectOffset;
                        if (offset.Offset == 0)
                        {
                            sb.AppendFormat("\t@{0}", offset.Register.ToString());
                        }
                        else
                        {
                            sb.AppendFormat("\t@{0}:0x{1:x}", offset.Register.ToString(), offset.Offset);
                        }
                    }
                }
            }
            return(sb.ToString());
        }
示例#2
0
     public byte[] GetBytes()
     {
         if (OperandAddressingMode == AddressingMode.INDIRECT_REG32 ||
             (OperandAddressingMode == AddressingMode.INDIRECT_REG16 ||
              (OperandAddressingMode == AddressingMode.INDIRECT_REG8)))
         {
             IndirectOffset off = Value as IndirectOffset;
             return(new byte[] { (byte)off.Register, (byte)(off.Offset & 0xFF), (byte)((off.Offset &
                                                                                        0xFF00) >> 8) });
         }
         else if (OperandAddressingMode == AddressingMode.IMMEDIATE_32)
         {
             return(BitConverter.GetBytes((uint)Value));
         }
         else if (OperandAddressingMode == AddressingMode.DIRECT_REGISTER)
         {
             return(BitConverter.GetBytes((byte)(Register)Value));
         }
         else if (OperandAddressingMode == AddressingMode.CONDITION_CODE)
         {
             return new byte[] { (byte)Value }
         }
         ;
         else
         {
             return new byte[] { }
         };
     }
 }