The opcode generated by:
or ebx, 0ffffffffh
with NASM is:
83CBFF
But in Intel Instructions Manual:
81 /1 id OR r/m32, imm32
83 /1 ib OR r/m32, imm8
My question is, why NASM used the opcode 83
instead of 81
, and how to generate the opcode 81
?
this is the command line for NASM: nasm -fwin32 file.asm -l list.lst
or eax, strict dword 0ffffffffh
to force a 32-bit operand. But this causes NASM to use the 0D opcode (or eax, imm32
) instead of 81. Of course, you can always just output the needed bytes withdb
. – Joleeeax
toebx
to avoid the special case ofOR EAX, imm32
– BiafraALIGN
macro? – WellspringALIGN
just causes NASM to emit a series ofNOP
s, @Ped7g, which is less efficient than a longer form of the same instruction. Might work in other assemblers, though. MASM is a bit smarter in how it adds padding. – Enrica%use smartalign
thenALIGNMODE p6, 32
. YASM has a much nicer default, using long NOPs in a way that's optimal for Intel P6 and SnB uarches. (Probably controlled by aCPU
directive or something, I forget). GNUas
's.p2align
also uses long NOPs by default. NASM is the exception, with nasty behaviour that will break the uop-cache by default. (More than 18 uops in a 32-byte chunk means that the code has to run from the decoders every time). – Athematicsmartalign
, though, probably because I've never actually used it and it didn't get cemented in long-term memory. – EnricaALIGN
directive, unfortunately. So you always get NOPs, instead of making the same instructions take more space "for free". – Athematic