logoalt Hacker News

loegtoday at 12:27 AM2 repliesview on HN

The decoder is an implementation detail that is a subcomponent of NOP; GP was right, and your correction isn't.


Replies

phiretoday at 4:43 AM

As specified by the spec, it arguably increments RIP by one.

The actual typical hardware implementation just fetches the next 16-32 bytes from icache, shifts it to the correct alignment, and slams it into a bunch of parallel decoders which each attempts to decode one x86 instruction per byte.

The next cycle, the first 1-6 non-overlapping valid instructions are accepted into a queue for further decoding. The NOP almost certainly takes up space in this queue.

At no point does RIP get incremented by one. There isn't even a single physical RIP register to increment, the CPU is "executing" dozens or even hundreds of RIPs in parallel.

fluoridationtoday at 12:56 AM

It's not an implementation detail, because the decoder runs before the execution of every instruction. If we're going to say that NOP increments IP by one, then we should also say that ADD "stores in dst the addition of src and dst, as well as incrementing IP by the length of the instruction", and JMP imm "increments JMP by imm + the length of the instruction".

show 1 reply