public static OpcodeEncoder AppendRM(this OpcodeEncoder encoder, Operand operand) { if (operand.IsCPURegister) { return(encoder.AppendRM(operand.Register)); } else { return(encoder.AppendRM(Bits.b101)); } }
public static OpcodeEncoder ModRegRMSIBDisplacement(this OpcodeEncoder encoder, Operand result, Operand op1, Operand op2) { if (op2.IsConstant) { encoder.AppendMod(true, op2); // 2:mod encoder.AppendRegister(result.Register); // 3:register (destination) encoder.AppendRM(op1); // 3:r/m (source) encoder.AppendConditionalDisplacement(op2); // 8/32:displacement value } else { encoder.AppendMod(Bits.b00); // 2:mod encoder.AppendRegister(result.Register); // 3:register (destination) encoder.AppendRM(Bits.b100); // 3:r/m (source) encoder.AppendSIB(1, op2.Register, op1.Register); // 8:sib (scale, index, base) } return(encoder); }