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); } }
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); }