Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why was NOP assigned to 0x90 in x86 assembly?

Why was nop assigned to 0x90 on intel x86 assembly?

Intuitively I would expect that 0x00 would map to nop (which is also xchg eax, eax at intel x86) as it is the case for ARM A32 and some other architectures.

like image 547
Jonas Stein Avatar asked May 01 '19 19:05

Jonas Stein


People also ask

What does NOP do in assembly?

What Does No Operation (NOP) Mean? A no operation or “no-op” instruction in an assembly language is an instruction that does not implement any operation. IT pros or others might refer to this as a blank instruction or placeholder.

Why is NOP required?

A NOP is most commonly used for timing purposes, to force memory alignment, to prevent hazards, to occupy a branch delay slot, to render void an existing instruction such as a jump, as a target of an execute instruction, or as a place-holder to be replaced by active instructions later on in program development (or to ...

Why is it called x86 assembly language?

x86 assembly language is the name for the family of assembly languages which provide some level of backward compatibility with CPUs back to the Intel 8008 microprocessor, which was launched in April 1972. It is used to produce object code for the x86 class of processors.

What is x86 assembly instructions?

The x86 instruction set refers to the set of instructions that x86-compatible microprocessors support. The instructions are usually part of an executable program, often stored as a computer file and executed on the processor.


1 Answers

0x00000000 is not actually NOP on ARM A32 though it behaves like one; it's actually andeq r0, r0, r0 whereas a real NOP is 0xe1a00000 (mov r0, r0). It's a rather bad idea to have the NUL byte be a NOP because that makes every empty memory region a free NOP slide, greatly increasing the risk for attacks. Modern architectures generally try to make all zeroes be a break instruction or similar to avoid this attack vector. For example, ARM A64 makes 0x00000000 a permanently undefined instruction udf 0.

0x90 is actually just one instruction of the 0x90 + r opcode family which stands for xchg r32, eax. eax is register 0, so 0x90 stands for xchg eax, eax which is a NOP. In long mode, 0x90 is special cased not to zero out the high 32 bit of rax to keep its function as a single byte NOP.

like image 161
fuz Avatar answered Sep 24 '22 03:09

fuz