A side: Showing text and reading keys

A A side · Assembly · The first language of the machine
How does the program talk to the person at the keyboard?
8 Assembly words in this segment
11 Fortran words for the same job
What Assembly says well here
- You call BIOS and DOS services directly: show text, read a key, change the screen mode.
What is hard to say
- No number formatting. To show a number, you change it to text, one digit at a time.
- A packed decimal counter is the smallest answer. Two bytes hold 0000 to 9999. Add with ADD and ADC, then DAA after each byte. AAM divides AL by 10 and gives the two digits in AH and AL.
One sentence in Assembly
mov ah, 09hmov dx, msgint 21h...msg db 'Hello$'It says: Ask DOS to show the text at msg. The $ marks the end of the text.
The words, by part of speech
Verbs (1) · An instruction: one step that the processor does, for example MOV or ADD.
| Word | Meaning | Example |
|---|---|---|
| INT | Call a service of the BIOS or DOS (a ready-made routine in the computer). | int 21h |
Idioms (7) · A BIOS or DOS service call, for example INT 21h with AH=09h: show a line of text.
| Word | Meaning | Example |
|---|---|---|
| INT 21h, AH=09h | DOS: show the text at DS:DX. A $ sign marks the end of the text. | mov ah, 09h |
| INT 21h, AH=02h | DOS: show one character. The character is in DL. | mov ah, 02h |
| INT 21h, AH=4Ch | DOS: stop the program and return to DOS. | mov ax, 4C00h |
| INT 16h, AH=00h | BIOS: wait for a key. The BIOS puts the key code in AX. | mov ah, 0 |
| INT 16h, AH=01h | BIOS: tell if a key is ready, without a wait. | mov ah, 1 |
| INT 10h, AX=0013h | BIOS: change the screen to 320 x 200 pixels with 256 colors (Mode 13h). | mov ax, 13h |
| INT 10h, AX=0003h | BIOS: change the screen to text mode again. | mov ax, 3 |
Watch out: what the review found
These notes come from the review of the AI-written guides. They show traps that are easy to miss.
- D02-M5 major This is too strong. Compilers from vendors of that time shipped graphics libraries that Fortran can call. An example is the graphics library of Microsoft FORTRAN 5.x. A call to a vendor or assembly library was normal practice. The Assembly path also depends on BIOS calls.
- D02-M10 major The document does not discuss distribution. Modern players will run the game in DOSBox or in a browser build. Emulator input latency, frame latency and host-display refresh (60 Hz, not 70 Hz) weaken the "zero-latency, locked 70 fps" promises.
- D13-M11 major The video gives the detail: the decimal flag does the carry (32:05), a 16-bit packed BCD counter holds "exactly the 10,000 I need", INC and DEC ignore the flag, so he uses ADC (32:05 to 32:26), and he suppresses leading zeros, except for the chicken counter (32:46 to 33:06). The claim is now checkable and correct.
- D15-M7 major The code does
bcdKillCounter + amounton a binary integer, thentoString().padStart(4, '0'). It is a decimal string, not BCD. It clamps at 9999 (measured: 9990 + 25 gives 9999). A decimal-mode ADC wraps to 0000 and sets the carry. The nibble display is correct. In the video, the chicken counter counts down and keeps its leading zeros [33:06]. The level counter counts up and drops them [32:26]. The one real trap in the video, INC and DEC ignore the flag [32:05], is absent from the simulator.