Hardware to Software:
The hardware works something like:
We as programmers approach this from the bottom!
We have a status register we can test and a buffer we can read. A small bonus we get is the keyboard controller will automatically turn off the RDY bit when we read the buffer.
Most of our work revolves around number 2 since 1,3,4 should be available in manuals. In the figure, we see a conceptual layout of four related items fu, bar, sna, fu. On the right we see how they are stored in physical memory. What would memory look like if we rearranged the items into the following order: bar, sna, fu, fu?
The keyboard control lends itself to incremental development. Rather than design, and code the whole thing, grow from a small piece of functionality. For example, interpret keystrokes first. Result: type h, see h@h. Next add release, shift, or control. Say we choose control. Result: type h see h#h, type ^h see ^h%^h. Until the release condition is handled, you will see a garbage character print to the screen.