A side: Making choices and repeating

A A side · Assembly · The first language of the machine
How do you say "if" and "again"?
13 Assembly words in this segment
13 Fortran words for the same job
What Assembly says well here
- The grammar is small and clear: compare two values, then jump to a label.
- You see each branch that the processor takes.
What is hard to say
- There is no IF ... ELSE block. A jump to the wrong label is an easy mistake.
One sentence in Assembly
cmp word [fuel], 0je no_fuelIt says: Compare fuel with 0. If they are equal, go to the label no_fuel.
The words, by part of speech
Verbs (10) · An instruction: one step that the processor does, for example MOV or ADD.
| Word | Meaning | Example |
|---|---|---|
| CMP | Compare two values. It subtracts but keeps only the flags. | cmp ax, 10 |
| TEST | Compare the bits of two values. It does an AND but keeps only the flags. | test al, 8 |
| JMP | Go to a label. | jmp game_loop |
| JE / JZ | Go to a label if the compared values are equal (the zero flag is 1). | je no_fuel |
| JNE / JNZ | Go to a label if the compared values are not equal. | jne again |
| JL / JG | Go to a label if less / greater (numbers with a sign). | jl too_low |
| JB / JA | Go to a label if below / above (numbers with no sign). | jb too_low |
| LOOP | Subtract 1 from CX. If CX is not 0, go to the label. | loop again |
| CALL | Go to a subroutine and remember the return address. | call draw_ship |
| RET | Return to the instruction after the CALL. | ret |
Nouns (2) · A register, a flag, a port or a place in memory, for example AX.
| Word | Meaning | Example |
|---|---|---|
| ZF | Zero flag. It is 1 when the last result is zero. | |
| SF | Sign flag. It is 1 when the last result is negative. |
Grammar marks (1) · Commas between operands, [square brackets] for memory, a colon after a label.
| Word | Meaning | Example |
|---|---|---|
| label: | A name for a place in the program. A colon ends it. | again: |
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-M7 major On real PCs, DRAM refresh, ISA wait states, the 8088 prefetch queue and 486 caches make exact cycle counts not practical. The claim is true on the C64 and NES. It is not true on the DOS target that the roadmap uses.