Skip to content

Try β€œpolymorphism”, β€œTCP handshake” or β€œgit rebase”.

    Computer Basics / How Computers Work

    The Whole Trip: "Hi πŸ˜€" From Keyboard to Screen

    Now let's use every earlier chapter together. You type Hi πŸ˜€ into StudyBuddy and press Save.

    Chapter 9 of 94 min read

    Now let's use every earlier chapter together. You type Hi πŸ˜€ into StudyBuddy and press Save.

      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   1. key press    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   2. becomes a     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      β”‚  Keyboard   β”‚ ────────────────▢ β”‚  Operating   β”‚ ──────────────────▢│ StudyBuddy  β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   electrical      β”‚  system      β”‚   "key event"      β”‚  process    β”‚
                        signal          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   for the app      β”‚  (in RAM)   β”‚
                                                                             β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                                                                    β”‚
          3. app stores the text as UTF-8 bytes in RAM:  48 69 20 F0 9F 98 80       β”‚
                                                                                    β–Ό
                                                                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          4. CPU runs the app's instructions (fetch–decode–execute),         β”‚    CPU      β”‚
             pulling those bytes through cache                               β”‚ + caches    β”‚
                                                                             β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                                                                    β”‚ 5. "Save"
                                                                                    β–Ό
                                                                             β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          6. the 7 bytes are written to the SSD, where they survive          β”‚    SSD      β”‚
             power-off                                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    
          7. to show the score, the app turns 200 into the characters "2","0","0",
             picks colour #FF8800, and the graphics hardware lights each pixel's
             red/green/blue parts β†’ you see an orange "200"

    Walk through it:

    1. Keyboard β†’ electrical signal. Pressing H closes a tiny circuit. The keyboard sends a code for "the H key".

    2. Operating system β†’ app. The operating system (next file) receives it and delivers a "key pressed" message to the program that's in front β€” StudyBuddy.

    3. Text becomes bytes (Chapter 4.3). The app stores Hi πŸ˜€ as 7 UTF-8 bytes somewhere in RAM, at some memory address (Chapter 7).

    4. The CPU does the work (Chapter 5). Every step β€” "add this character", "redraw this line" β€” is the app's instructions (Chapter 8) running through fetch–decode–execute, with data pulled into cache (Chapter 6).

    5. Save is pressed. The app asks the operating system to write the bytes to a file.

    6. Bytes reach the SSD (Chapter 6). Now they survive power-off.

    7. The score appears. The number 200 is stored as binary 1100 1000 (Chapter 2). To show it, the app converts it into the characters 2, 0, 0 (Chapter 4.3), and draws them in colour #FF8800 (Chapter 3) β€” pixels with red 255, green 136, blue 0 (Chapter 4.4).

    The number 200 and the text "200" are different things. The number is 1 byte (C8). The text is 3 bytes (32 30 30 in ASCII/UTF-8). Converting between them is called parsing (text β†’ number) and formatting (number β†’ text). You'll do this constantly: every web form, every API request, every file you read.

    Check yourself

    3 questions
    1

    In the trip above, which step makes the note survive a power cut?

    Show answer

    Step 6, writing the bytes to the SSD (persistent storage). Before that they were only in RAM.

    2

    How is the number 200 stored differently from the text "200"?

    Show answer

    The number is one byte 0xC8 (binary 1100 1000); the text is three character bytes 0x32 0x30 0x30.

    3

    What did the operating system do in this trip? (We'll go much deeper in the next file.)

    Show answer

    It passed the key press to the right program, loaded the program into RAM, and handled writing the file to disk.