Once we know what a CPU does, we can figure out how long it takes to do it.
This is the thirteenth 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. The homework files (listing 56, and optionally 57) are available on the github.
By taking a limited look at the 8086, we now have the ability to read assembly language and turn it into a mental model of what the CPU is actually doing. This is a crucial skill for performance-aware programming. But of course, I’ve already said many times that we only need to read assembly language, not write it. Wouldn’t we have to write assembly language to make it useful for performance?
Surprisingly, the answer is usually “no”. What we really need most often is to be able to read assembly language and determine what the expected performance should be for a sequence of instructions. This basic skill, which we’ll start learning in today’s homework, is the cornerstone of three important performance-programming activities: