0

I want to know that how can I convert a single opcode with it's operands in it's equivalent assembly code. For example:

Opcode:33 C0

Assembly code: XOR AX,AX

As mentioned above, I want to put "33 C0" into the program (or software) and it should display it's equivalent assembly code result, as given below:

XOR AX, AX

In the same way when i change the opcode little bit to "33 C9" then it should display it's equivalent assembly code, as given below:

Opcode: 33 C9

Assembly code: XOR CX, CX

I will be grateful if you guide me it's revers process (i.e. when I enter the assembly code then it should see it's equivalent opcode), for example:

I enter: XOR AX, AX Then it should display: 33 C0

In the same way when i enter XOR CX, CX Then it should display: 33 C9

I want to get these results instruction by instruction and not in chunk of a lot of code. I tried several softwares for this purpose but they cannot convert instruction by instruction rather they provide a chunk of result which get faulty.

Thanks.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • 1
    Have you tried something like the libcapstone? It is certainly possible to implement this logic yourself, but it can get kind of tricky to get right. – fuz Jul 19 '22 at 04:17
  • 1
    I typically use [this](https://defuse.ca/online-x86-assembler.htm#disassembly2). The top box produces the op codes, the bottom box does the reverse. Note that things can "get faulty" if the codes you are creating don't form valid instructions. – David Wohlferd Jul 19 '22 at 06:33
  • Note that `33 C0` is `xor eax,eax` in 32 and 64-bit mode. Only in 16-bit mode is it `xor ax,ax`. I tagged your question as such. If you're using an online disassembler, you can generally prefix any instruction with `66 67` to make the operand and address sizes 16-bit. (Unless the instruction contains such prefixes; in 16-bit mode that means make it 32, so you'd need to omit it for a 32-bit disassembler.) – Peter Cordes Jul 19 '22 at 12:36
  • Disassemblers like `ndisasm` and `objdump -d -M i8086` will properly disassemble 16-bit binary machine code, so `xxd` to undump hex and pipe into it I think. [How do I disassemble raw 16-bit x86 machine code?](https://stackoverflow.com/q/1737095) – Peter Cordes Jul 19 '22 at 12:36

0 Answers0