Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Fix disassembly of mov drX, reg #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assembly/nmd_x86_decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ NMD_ASSEMBLY_API bool nmd_x86_decode(const void* const buffer, size_t buffer_siz
else if (op >= 0x20 && op <= 0x23)
{
instruction->operands[0].type = instruction->operands[1].type = NMD_X86_OPERAND_TYPE_REGISTER;
instruction->operands[op < 0x22 ? 0 : 1].fields.reg = NMD_X86_REG_EAX + instruction->modrm.fields.rm;
instruction->operands[op < 0x22 ? 0 : 1].fields.reg = (uint8_t)(instruction->mode == NMD_X86_MODE_64 ? (instruction->prefixes & NMD_X86_PREFIXES_REX_B ? NMD_X86_REG_R8 : NMD_X86_REG_RAX) : NMD_X86_REG_EAX) + instruction->modrm.fields.rm;
instruction->operands[op < 0x22 ? 1 : 0].fields.reg = (uint8_t)((op % 2 == 0 ? NMD_X86_REG_CR0 : NMD_X86_REG_DR0) + instruction->modrm.fields.reg);
instruction->operands[0].action = NMD_X86_OPERAND_ACTION_WRITE;
instruction->operands[1].action = NMD_X86_OPERAND_ACTION_READ;
Expand Down
2 changes: 1 addition & 1 deletion nmd_assembly.h
Original file line number Diff line number Diff line change
Expand Up @@ -5475,7 +5475,7 @@ NMD_ASSEMBLY_API bool nmd_x86_decode(const void* const buffer, size_t buffer_siz
else if (op >= 0x20 && op <= 0x23)
{
instruction->operands[0].type = instruction->operands[1].type = NMD_X86_OPERAND_TYPE_REGISTER;
instruction->operands[op < 0x22 ? 0 : 1].fields.reg = NMD_X86_REG_EAX + instruction->modrm.fields.rm;
instruction->operands[op < 0x22 ? 0 : 1].fields.reg = (uint8_t)(instruction->mode == NMD_X86_MODE_64 ? (instruction->prefixes & NMD_X86_PREFIXES_REX_B ? NMD_X86_REG_R8 : NMD_X86_REG_RAX) : NMD_X86_REG_EAX) + instruction->modrm.fields.rm;
instruction->operands[op < 0x22 ? 1 : 0].fields.reg = (uint8_t)((op % 2 == 0 ? NMD_X86_REG_CR0 : NMD_X86_REG_DR0) + instruction->modrm.fields.reg);
instruction->operands[0].action = NMD_X86_OPERAND_ACTION_WRITE;
instruction->operands[1].action = NMD_X86_OPERAND_ACTION_READ;
Expand Down