Use the int3
mnemonic for the special one-byte encoding.
nasm -l /dev/stdout /tmp/foo.asm
1 00000000 CD03 int 3
2 00000002 CC int3
From the Intel's insn set manual entry for int
:
An interrupt generated by INTO
or INT3
(CC) differs from one generated by INT n
in the following ways:
The normal IOPL checks do not occur in virtual-8086 mode. The interrupt is taken (without fault) with any IOPL value.
The interrupt redirection enabled by the virtual-8086 mode extensions (VME) does not occur. The interrupt is always handled by a protected-mode handler.
These features do not pertain to CD03, the “normal” 2-byte opcode for INT 3
It also says:
Intel and Microsoft assemblers will not generate the CD03 opcode from any mnemonic
because there aren't any normal / common use-cases for the 2-byte encoding. NASM keeps it simple and always uses the CD
opcode for the int
mnemonic.
When NASM does optimize things like mov rax, 1
to mov eax,1
, it's a different opcode that uses the same mnemonic. IDK if it would have been inconvenient to implement, or if NASM simply decided not to. It makes sense to think of int3
as a special instruction, different from int n
, though, because it's only 1 byte.