3 ms·
The easiest way of doing padding is to add a bunch of `nop` instructions which are one byte each. If you read the manual, Intel encourages minor variations of
by kccqzy 3y ago
The easiest way of doing padding is to add a bunch of `nop` instructions which are one byte each.
If you read the manual, Intel encourages minor variations of the `nop` instructions that can be lengthened into different number of bytes (like `nop dword ptr [eax]` or `nop dword ptr [eax + eax*1 + 00000000h]`).
It is never recommended anywhere in my knowledge to rely on redundant prefixes of random non-nop instructions.
- deleted 3y ago[deleted]
- epcoa 3y agoNOPs are not generally free. It's a pretty old and well known technique: https://stackoverflow.com/questions/48046814/what-methods-can-be-used-to-efficiently-extend-instruction-length-on-modern-x86 https://stackoverflow.com/questions/48046814/what-methods-ca... Note that this technique is really only legitimate where the used prefix already has defined behavior with the given instruction ("Use of repeat prefixes and/or undefined opcodes with other Intel 64 or IA-32 instructions is reserved; such use may cause unpredictable behavior."), and of course the REX prefix has special limitations. The key is redundant, not spurious. It is not a good idea to be doing rep add for example. But otherwise, there is no issue.