4 ms·
It increments rip by one.
by jooops1 2mo ago
It increments rip by one.
- fluoridation 2mo agoNo, that's done by the decoder. It actually does nothing.
- russdill 2mo agoI mean....there are several architectures out there which has a nop that is a jump forward. Kind of a tree forest issue imho
- fluoridation 2mo agoI don't know about other architectures in as much detail. I know x86 NOP does nothing.
- loeg 2mo agoThe decoder is an implementation detail that is a subcomponent of NOP; GP was right, and your correction isn't.
- fluoridation 2mo agoIt'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".
- loeg 2mo agoADD does in fact do that.
- fluoridation 2mo agoI'm not disputing the total effect. I'm asking if you'd rather describe ADD and JMP in this manner, in order to say that NOP does not in fact do nothing.
- dxdm 2mo agoLove the pedantry here. I'm currently at: no op code does anything, it's all fancy effects in the hardware that can be described in arbitrary detail, which somehow allows me to cause these letters to appear on your screen.
- fluoridation 2mo agoInsightful and compelling. Tell me another one.
- dxdm 2mo agoWith pleasure. There was a boy A very strange, enchanted boy They say he wandered very far Very far, over land and sea A little shy and sad of eye But very wise was he. And then one day A magic day he passed my way And while we spoke of many things Fools and kings This he said to me: "The greatest thing you'll ever learn Is just to love and be loved in return."
- phire 2mo agoAs 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.
- amluto 2mo agoAs long as everyone is being outrageous pedantic: NOP, like all other non-faulting, non-control-transferring instructions, increments RIP by the length of the instruction, which may or may not be one. A prefixed NOP is still NOP.
- dlcarrier 2mo agoIt's still part of the instruction to increment it by one, as opposed to write a value or offset to it, as jump instructions do.
- fluoridation 2mo agoSee my sibling response.
- EvanAnderson 2mo agoI thought I remembered reading somewhere re: the 8086 microcode disassembly that NOP, which is encoded as XCHG AX,AX actually does run the XCHG microcode and uses an internal scratchpad register to do the exchange.
- JoeAltmaier 2mo agoThere were several NOPs - XCHG BX,BX and so on. Those were taken later to be prefixes for new classes of opcodes.
- bonzini 2mo agoNone was. XCHG AX,AX is special because XCHG AX,reg has a one-byte encoding. You're probably confusing with: - POP CS being broken and later becoming a prefix - some opcodes being "reserved NOPs", i.e. reserved without generating #UD. They are used for instructions that may be defined in the future while guaranteeing backwards compatibility, for example new kinds of prefetches. MPX bounds checking instructions were also encoded in reserved NOPs.
- JoeAltmaier 2mo agoWas I thinking of 0x86?
- bonzini 2mo ago0x86 and 0x87 (XCHG rm,r with byte- and word-sized operands) encode nops in the same way as 0x90, but were never redefined as prefixes. It's interesting that a lot of ALU operations occupy four opcodes (memory source/memory destination x byte/word) but 0x84/0x85 and 0x86/0x87 only need two because not only are they commutative, but also 0x84/0x85 do not write to any operands and 0x86/0x87 write to both. So there is no difference between memory as the source or destination operand.