Assembly 指令中的XOP前缀是什么?
我最近一直在阅读一些源代码,这特别吸引了我的眼球:Assembly 指令中的XOP前缀是什么?,assembly,x86,machine-code,instructions,amd-processor,Assembly,X86,Machine Code,Instructions,Amd Processor,我最近一直在阅读一些源代码,这特别吸引了我的眼球: /** * Decodes the `XOP`-prefix. * * @param context A pointer to the `ZydisDecoderContext` struct. * @param instruction A pointer to the `ZydisDecodedInstruction` struct. * @param data The `XOP` bytes.
/**
* Decodes the `XOP`-prefix.
*
* @param context A pointer to the `ZydisDecoderContext` struct.
* @param instruction A pointer to the `ZydisDecodedInstruction` struct.
* @param data The `XOP` bytes.
*
* @return A zyan status code.
*/
static ZyanStatus ZydisDecodeXOP(ZydisDecoderContext* context,
ZydisDecodedInstruction* instruction, const ZyanU8 data[3])
{
ZYAN_ASSERT(instruction);
ZYAN_ASSERT(data[0] == 0x8F);
ZYAN_ASSERT(((data[1] >> 0) & 0x1F) >= 8);
ZYAN_ASSERT(instruction->raw.xop.offset == instruction->length - 3);
instruction->attributes |= ZYDIS_ATTRIB_HAS_XOP;
instruction->raw.xop.R = (data[1] >> 7) & 0x01;
instruction->raw.xop.X = (data[1] >> 6) & 0x01;
instruction->raw.xop.B = (data[1] >> 5) & 0x01;
instruction->raw.xop.m_mmmm = (data[1] >> 0) & 0x1F;
if ((instruction->raw.xop.m_mmmm < 0x08) || (instruction->raw.xop.m_mmmm > 0x0A))
{
// Invalid according to the AMD documentation
return ZYDIS_STATUS_INVALID_MAP;
}
instruction->raw.xop.W = (data[2] >> 7) & 0x01;
instruction->raw.xop.vvvv = (data[2] >> 3) & 0x0F;
instruction->raw.xop.L = (data[2] >> 2) & 0x01;
instruction->raw.xop.pp = (data[2] >> 0) & 0x03;
// Update internal fields
context->cache.W = instruction->raw.xop.W;
context->cache.R = 0x01 & ~instruction->raw.xop.R;
context->cache.X = 0x01 & ~instruction->raw.xop.X;
context->cache.B = 0x01 & ~instruction->raw.xop.B;
context->cache.L = instruction->raw.xop.L;
context->cache.LL = instruction->raw.xop.L;
context->cache.v_vvvv = (0x0F & ~instruction->raw.xop.vvvv);
return ZYAN_STATUS_SUCCESS;
}
这里的代码实际上并不重要:我想知道的是XOP前缀是什么。英特尔或AMD的文档中没有提到这一点,我发现几乎没有信息
有人知道是什么吗?它是AMD指令唯一的前缀吗?如果是,它与英特尔的对应物是什么?可能是这个?通过谷歌搜索xop前缀x86可以找到很多答案:xop是AMD唯一的前缀,用于推土机/打桩机/蒸汽压路机/挖掘机芯片中提供的AMD特定SIMD指令。第一个字节是8F,后面是另外两个字节,然后是一个操作码。有关详细信息,请参阅AMD手册。英特尔对应的VEX前缀非常类似,用于AVX和一些BMI指令等。