Skip to content

Commit

Permalink
Fix x86-16 mode (patch imported from radare2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ret2libc committed Dec 15, 2020
1 parent 455a0d0 commit 48ed89e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/X86/X86ATTInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,9 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
if (MI->Opcode == X86_CALLpcrel16 || MI->Opcode == X86_JMP_2)
imm = imm & 0xffff;

if (MI->csh->mode == CS_MODE_16)
imm |= (MI->address >> 16) << 16;

if (imm < 0) {
SStream_concat(O, "0x%"PRIx64, imm);
} else {
Expand Down
3 changes: 3 additions & 0 deletions arch/X86/X86IntelInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,9 @@ static void printPCRelImm(MCInst *MI, unsigned OpNo, SStream *O)
if (MI->Opcode == X86_CALLpcrel16 || MI->Opcode == X86_JMP_2)
imm = imm & 0xffff;

if (MI->csh->mode == CS_MODE_16)
imm |= (MI->address >> 16) << 16;

printImm(MI, O, imm, true);

if (MI->csh->detail) {
Expand Down

0 comments on commit 48ed89e

Please sign in to comment.