Stories
Slash Boxes
Comments

SoylentNews is people

posted by janrinok on Saturday March 11, @12:18PM   Printer-friendly

https://www.righto.com/2023/02/how-8086-processor-determines-length-of.html

The Intel 8086 processor (1978) has a complicated instruction set with instructions ranging from one to six bytes long. This raises the question of how the processor knows the length of an instruction.1 The answer is that the 8086 uses an interesting combination of lookup ROMs and microcode to determine how many bytes to use for an instruction. In brief, the ROMs perform enough decoding to figure out if it needs one byte or two. After that, the microcode simply consumes instruction bytes as it needs them. Thus, nothing in the chip explicitly "knows" the length of an instruction. This blog post describes this process in more detail.

[...] The 8086 uses a 6-byte instruction prefetch queue to hold instructions, and this queue will play an important role in this discussion.3 Earlier microprocessors read instructions from memory as they were needed, which could cause the CPU to wait on memory. The 8086, instead, read instructions from memory before they were needed, storing them in the instruction prefetch queue. (You can think of this as a primitive instruction cache.) To execute an instruction, the 8086 took bytes out of the queue one at a time. If the queue ran empty, the processor waited until more instruction bytes were fetched from memory into the queue.


Original Submission

 
This discussion was created by janrinok (52) for logged-in users only, but now has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 3, Interesting) by kazzie on Sunday March 12, @12:08PM

    by kazzie (5309) Subscriber Badge on Sunday March 12, @12:08PM (#1295761)

    With a modern head on, I've looked at fixed-length instructions as being a far saner approach, as I didn't want to try to wrap my head around implementing identifying instructions of length 1-to-N. (Granted, memory wasn't as freely available back then, but this is a view in hindsight.)

    For some reason, it never occurred to me to think of it as a done/not-done binary decision, and keep on fetching until the executed microcode flagged that the instruction was finished.

    Starting Score:    1  point
    Moderation   +1  
       Interesting=1, Total=1
    Extra 'Interesting' Modifier   0  
    Karma-Bonus Modifier   +1  

    Total Score:   3