public abstract void Write(MachineInstructionWriter writer, MachineInstructionWriterOptions options);
public override void Write(MachineInstructionWriter writer, MachineInstructionWriterOptions options) { writer.WriteAddress(Address.ToString(), Address); }
public override void Write(MachineInstructionWriter writer, MachineInstructionWriterOptions options) { writer.Write("st(" + fpuReg + ")"); }
public override void Render(MachineInstructionWriter writer, MachineInstructionWriterOptions options) { if (repPrefix == 3) { writer.WriteOpcode("rep"); writer.WriteChar(' '); } else if (repPrefix == 2) { writer.WriteOpcode("repne"); writer.WriteChar(' '); } // Get opcode. string s = code.ToString(); switch (code) { case Opcode.cwd: if (dataWidth == PrimitiveType.Word32) { s = "cdq"; } break; case Opcode.cbw: if (dataWidth == PrimitiveType.Word32) { s = "cwde"; } break; case Opcode.ins: case Opcode.outs: case Opcode.movs: case Opcode.cmps: case Opcode.stos: case Opcode.lods: case Opcode.scas: switch (dataWidth.Size) { case 1: s += 'b'; break; case 2: s += 'w'; break; case 4: s += 'd'; break; case 8: s += 'q'; break; default: throw new ArgumentOutOfRangeException(); } break; } writer.WriteOpcode(s); if (NeedsExplicitMemorySize()) { options |= MachineInstructionWriterOptions.ExplicitOperandSize; } if (Operands >= 1) { writer.Tab(); Write(op1, writer, options); if (Operands >= 2) { writer.WriteChar(','); Write(op2, writer, options); if (Operands >= 3) { writer.WriteString(","); Write(op3, writer, options); } } } }
public override void Write(MachineInstructionWriter writer, MachineInstructionWriterOptions options) { writer.WriteString(Code.ToString()); }
public override void Render(MachineInstructionWriter writer, MachineInstructionWriterOptions options) { nInstr.Render(writer, options); }
protected override void RenderOperand(MachineOperand op, MachineInstructionWriter writer, MachineInstructionWriterOptions options) { switch (op) { case RegisterOperand reg: WriteRegister(reg.Register, writer); break; case ImmediateOperand imm: if (imm.Width.Domain == Domain.Real) { writer.WriteFormat($"#{imm.Value}"); } else { int v = imm.Value.ToInt32(); if (0 <= v && v <= 9) { writer.WriteFormat($"#{imm.Value.ToInt32()}"); } else { writer.WriteFormat($"#&{imm.Value.ToUInt32():X}"); } } break; case AddressOperand addrOp: ulong linAddr = addrOp.Address.ToLinear(); writer.WriteAddress($"#&{linAddr:X}", addrOp.Address); break; default: op.Write(writer, options); break; } }
protected override void RenderOperand(MachineOperand op, MachineInstructionWriter writer, MachineInstructionWriterOptions options) { if (op is MemoryOperand memOp && memOp.Base == Registers.rip) { var addr = this.Address + this.Length + memOp.Offset.ToInt32(); if ((options & MachineInstructionWriterOptions.ResolvePcRelativeAddress) != 0) { writer.WriteString("["); writer.WriteAddress(addr.ToString(), addr); writer.WriteString("]"); writer.AddAnnotation(op.ToString()); } else { op.Write(writer, options); writer.AddAnnotation(addr.ToString()); } }