Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected Operand in Decoder Output for Multi-byte NOP Instructions #563

Open
zouxianyu opened this issue Mar 29, 2025 · 1 comment
Open
Labels
A-decoder Area: Decoder

Comments

@zouxianyu
Copy link

The Intel Software Developer's Manual defines three encodings for the NOP instruction:

  • NOP
  • NOP r/m16
  • NOP r/m32

Additionally, Intel recommends specific multi-byte NOP encodings for alignment purposes, as shown below:

Length Assembly Byte Sequence
2 bytes 66 NOP 66 90H
3 bytes NOP DWORD ptr [EAX] 0F 1F 00H
4 bytes NOP DWORD ptr [EAX + 00H] 0F 1F 40 00H
5 bytes NOP DWORD ptr [EAX + EAX*1 + 00H] 0F 1F 44 00 00H
6 bytes 66 NOP DWORD ptr [EAX + EAX*1 + 00H] 66 0F 1F 44 00 00H
7 bytes NOP DWORD ptr [EAX + 00000000H] 0F 1F 80 00 00 00 00H
8 bytes NOP DWORD ptr [EAX + EAX*1 + 00000000H] 0F 1F 84 00 00 00 00 00H
9 bytes 66 NOP DWORD ptr [EAX + EAX*1 + 00000000H] 66 0F 1F 84 00 00 00 00 00H

However, when these instructions are disassembled using Zydis, the decoded output differs slightly:

Length Decode Result
2 bytes nop
3 bytes nop [rax], eax
4 bytes nop [rax], eax
5 bytes nop [rax+rax*1], eax
6 bytes nop [rax+rax*1], ax
7 bytes nop [rax], eax
8 bytes nop [rax+rax*1], eax
9 bytes nop [rax+rax*1], ax

This reveals a discrepancy: Zydis sometimes interprets multi-byte NOP sequences as having an additional operand.

@mappzor
Copy link
Contributor

mappzor commented Mar 29, 2025

Seems this issue is basically an inverse of #539. We should probably review all nops and handle them in a uniform way, with or without extra operands. Personally I'm not sure which version would be better.

@mappzor mappzor added the A-decoder Area: Decoder label Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-decoder Area: Decoder
Projects
None yet
Development

No branches or pull requests

2 participants