private void memindex_emit(BinaryWriter writer, Byte r, X86Register32 basereg, Int32 disp, X86Register32 indexreg, Byte shift) { if (basereg == X86Register32.None) { address_byte(writer, 0, (byte)r, 4); address_byte(writer, (byte)shift, (byte)indexreg, 5); writer.Write((Int32)disp); } else if (disp == 0 && basereg == X86Register32.EBP) { address_byte(writer, 0, (byte)r, 4); address_byte(writer, (byte)shift, (byte)indexreg, (byte)basereg); } else if (X86Writer.is_imm8(disp)) { address_byte(writer, 1, (byte)r, 4); address_byte(writer, (byte)shift, (byte)indexreg, (byte)basereg); writer.Write((Byte)disp); } else { address_byte(writer, 2, (byte)r, 4); address_byte(writer, (byte)shift, (byte)indexreg, 5); writer.Write((Int32)disp); } }
internal static byte[] GetAsmBytes(IntPtr address, Action <X86Writer> writeAction) { //write asm to memory stream MemoryStream stream = new MemoryStream(); X86Writer writer = new X86Writer(stream, address); writeAction.Invoke(writer); return(stream.ToArray()); }
private void membase_emit(BinaryWriter writer, Byte r, X86Register32 basereg, Int32 disp) { do { if ((basereg) == X86Register32.ESP) { if ((disp) == 0) { address_byte(writer, 0, (byte)r, (byte)X86Register32.ESP); address_byte(writer, 0, (byte)X86Register32.ESP, (byte)X86Register32.ESP); } else if (X86Writer.is_imm8(disp)) { address_byte(writer, 1, (byte)r, (byte)X86Register32.ESP); address_byte(writer, 0, (byte)X86Register32.ESP, (byte)X86Register32.ESP); writer.Write((byte)(disp)); } else { address_byte(writer, 2, (byte)r, (byte)X86Register32.ESP); address_byte(writer, 0, (byte)X86Register32.ESP, (byte)X86Register32.ESP); writer.Write(disp); } break; } else if (disp == 0 && basereg != X86Register32.EBP) { address_byte(writer, 0, (byte)r, (byte)basereg); } else if (X86Writer.is_imm8(disp)) { address_byte(writer, 1, (byte)r, (byte)basereg); writer.Write((byte)(disp)); } else { address_byte(writer, 2, (byte)r, (byte)basereg); writer.Write(disp); } } while (false); }
internal X86Label(X86Writer writer, IntPtr position) { this.writer = writer; mark = position; }
internal X86Label(X86Writer writer) { this.writer = writer; }