I understand that when a program runs, it stores data (like variables) and also instructions which act upon that data in the RAM. The CPU executes the instructions, and the data is played around with according to those instructions. (I am not talking about special-cases or reflective programming languages that treat instructions as data).
My question is this: how does this translate into an actual hardware output and input? How does the manipulation of the data done by the instructions actually generate a monitor/speaker output, or receive keyboard/mouse input?
After doing some research I figured out that it has to do with the underlying OS, and that the OS acts as a "bridge" between the application and the hardware, but I didn't connect all the pieces of the puzzle yet. What exactly happens behind the scene when we call Printf(); or a similiar function?
Topics that may be (or may not be) related:
Windows API - Wikipedia, the free encyclopedia
OpenGL - Wikipedia, the free encyclopedia
Any shared thoughts would be appreciated.