Instruction Decoding on the 8086
Even in the beginning, it was... complicated.
This is the first video in Part 1 of the Performance-Aware Programming series. Please see the Table of Contents to quickly navigate through the rest of the course as it is updated weekly. Homework data is available on the github. A lightly-edited transcript of the video appears below.
In my experience, the easiest way to understand how something works is to build one yourself. If you know how something works, you can build it. If you don't know how something works, you definitely can't.
What I'd like to do for the first part of this course is to have you build a virtual CPU in software — not the whole thing, because we don't need to go that far just for educational purposes. And we certainly don't need to ever fabricate the CPU, so we only need to simulate it’s functionality, not its actual circuitry. But the goal will be to build enough of a CPU simulation that you deeply understand how it functions.
I don't want to overwhelm anybody with all of the components that you would find in something like a modern Alder Lake or Zen4 CPU. They're incredibly complicated because they represent over forty years of continuous evolution on the x86 architecture.
So in order to keep things simple enough to fit in a reasonable set of homework assignments, I'd like to rewind all the way back to the original 8086 that started the whole lineage. This was the original CPU architecture used in the very first IBM PC1.