So, I am a noob in assembly language and machine instructions.
When the discussion came up as to how funtion calls are implemented at the processor level, someone said that the
CALL instruction pushes the address of the next instruction to be executed on the stack before updating the
EIP and then someone asked how do we know the address of the next instruction.
And then someone asked while
EIP points to the current instruction in memory how does the processor know how many bytes from
EIP need to be read so that the whole instruction is read.
I assumed that all instructions are fixed length so the processor would read those many bytes as would constitute the instruction and then the decoding process would determine how many more bytes need to be read to fetch the operands. However when searching about the instructions I came to know that the instruction sizes vary.
So we are back to the same question: How does the processor know the number of bytes to read to get the instruction from memory to the instruction cache?