Skip to content

Commit

Permalink
Add detailed comments about operand types
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Dec 27, 2023
1 parent 2a88129 commit 8bc9757
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions instructionAPI/src/x86/decoder.C
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ namespace Dyninst { namespace InstructionAPI {
return;
}

/* Decode _explicit_ operands
*
* There are three types of these for x86:
*
* add r1, r2 ; r1, r2 are both X86_OP_REG
* jmp -64 ; -64 is X86_OP_IMM
* mov r1, 0x33 ; r1 is X86_OP_REG, 0x33 is X86_OP_MEM
*/
auto* d = dis.insn->detail;
for(uint8_t i = 0; i < d->x86.op_count; ++i) {
cs_x86_op const& operand = d->x86.operands[i];
Expand All @@ -130,6 +138,18 @@ namespace Dyninst { namespace InstructionAPI {
}
}

/* Decode _implicit_ operands
*
* These are operands which are not part of the opcode. Some opcodes
* have both explicit and implicit operands. For example,
*
* add r1, r2 ; {e,r}flags is written to implicitly
* jmp -64 ; PC/IP is written to implicitly
*
* Some have only implicit:
*
* pop ; modifies stack pointer {e,r}sp
*/
// The key is a Capstone register enum
// The value is a pair of boolean, where the first represnet whether read or not
// and the second one represents whether written or not
Expand Down

0 comments on commit 8bc9757

Please sign in to comment.