0

Considering the x86 instruction set contains variable-length instructions, how does jmp knows where an instruction ends? For example

0:  01 c0                   add    eax,eax
2:  e9 fc ff ff ff          jmp    0

How does the system know "0" will refer to an instruction of length 2, namely, 01 c0, rather than an instruction of length 4, namely, "01 c0 e9 fc" in this case?

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
zell
  • 8,807
  • 8
  • 50
  • 99
  • 1
    duplicates: [How does the CPU/assembler know the size of the next instruction?](https://stackoverflow.com/q/25101978/995714), [How does the CPU know how many bytes it should read for the next instruction, considering instructions have different lenghts?](https://stackoverflow.com/q/56385995/995714), [How does the CPU decode variable length instructions correctly?](https://stackoverflow.com/q/25129165/995714), [With variable length instructions how does the computer know the length of the instruction being fetched?](https://stackoverflow.com/q/24269368/995714) – phuclv Nov 02 '21 at 14:25

0 Answers0