NOP Instruction in x86-64

In x86-64 assembly, NOP (pronounced ‘nop’ or ‘no-op’) is an instruction that doesn’t do anything. Unlike other instructions, it does not change the value of a register, a flag, or location in memory. It simply gets executed by the processor, which then proceeds to the next instruction.

The interesting thing about NOP is the fact that it can be useful to have an instruction that doesn’t do anything. It can be used as a timing delay or a placeholder, among other things. NOP is commonly used for debugging. It also finds frequent use in the development of exploit code for vulnerabilities such as buffer overflows.

In x86-64 assembly, the NOP instruction is represented by the mnemonic ‘NOP'.

NOP is encoded as a single-byte instruction and has an opcode of 0x90. It’s essentially a placeholder instruction that doesn’t perform any useful computation but is used for a variety of other purposes.

Here’s the simplest possible example of NOP (likely the simplest possible example of assembly code!):

section .text
    global _start

_start:
    NOP

This lovely code doesn’t do anything, because the only instruction is NOP. The _start label is by convention used as the entry point for executable programs.

NOP in x86-64

In x86 and x64 assembly, NOP is technically a mnemonic for the instruction:

XCHG EAX, EAX

This simply exchanges the value of the EAX register for itself. Therefore in x86-64, the NOP instruction does technically interact with the EAX register, but it doesn’t change its value. This trait is unique to x86-64 assembly, however.