(Indeed, the data is being transfered between an IO device and the memory, and not between IO device and the CPU, because there is no space inside the CPU to hold the vast amount of data that is being transfered.)
When the CPU performs the IO operation, the technique is called "programmed IO".
Before I can show you exactly what happens in programmed IO, I need to make some assumptions about the computer system...
The following are the assumptions for the computer system:
Schematically:
To put things in perspective:
(Assume String myString = "ABCDEFGHIJ";) System.output.print(myString);
If the computer system uses programmed IO, the program statement "System.output.print(myString)" will generate an assembler program that instruct the CPU to do the IO communication with the intended IO device (in this case, the printer).
The Java statement:
System.output.print(myString)(assume variable myString = "ABCDEFGHIJ";) will translate into the following assembler program that prints the (10) characters in the variable "myString" to the printer:
* Memory address 2000 = status register of printer * Memory address 2004 = data register of printer * Memory address 2008 = command register of printer move.l #myString, A0 // A0 points to the first character in myString move.l #10, D0 // D0 = count Loop: move.l 2000, D1 // Read printer status cmp.l #0, D1 // Check if printer is idle bne Loop // Wait until printer is idle before you can send the next character to printer // Now the printer status = idle... move.b (A0), 2004 // Send next character to be printer move.l #1, 2008 // Tell printer to print adda.l #1, A0 // Make A0 point to next character in myString sub.l #1, D0 cmp.l #0, D0 // Check if all characters printed... bne Loop // Loop if not done... .... myString: dc.b 'ABCDEFGHIJ' // The ASCII codes of the string
BUT... in doing so, we create two new problems...
We will see this next...