Skip to content

A side: Working with many values

A cassette tape with a handwritten label: "A Side. Assembly - the first language of the machine."

A A side · Assembly · The first language of the machine

How do you do one thing to a long list of values?

8 Assembly words in this segment
15 Fortran words for the same job

What Assembly says well here

  • String verbs with the REP adverb copy or fill memory very fast: one sentence, done CX times.
  • This is the best tool to move screen pixels in a retro game.
  • The lander does not search for the ground. It reads one byte: the height of the ground in the column of the ship. The B side makes that table.

What is hard to say

  • You write each loop yourself. There is no ready-made word for sum or average.
  • REP MOVSW copies every byte, also the bytes that did not change. A black pixel costs the same as a yellow one. The machine counts work that you cannot see.

One sentence in Assembly

mov ax, 0A000h
mov es, ax
xor di, di
mov al, 1
mov cx, 64000
rep stosb

It says: Fill all 64,000 screen pixels with color 1.

The words, by part of speech

Verbs (6) · An instruction: one step that the processor does, for example MOV or ADD.

WordMeaningExample
MOVSBCopy one byte from DS:SI to ES:DI, then move SI and DI to the next byte.rep movsb
MOVSWCopy one word (2 bytes) from DS:SI to ES:DI.rep movsw
STOSBPut AL at ES:DI, then move DI to the next byte.rep stosb
STOSWPut AX at ES:DI, then move DI 2 bytes.rep stosw
LODSBLoad the byte at DS:SI into AL, then move SI.lodsb
CLDMake the string verbs move forward (clear the direction flag).cld

Nouns (1) · A register, a flag, a port or a place in memory, for example AX.

WordMeaningExample
DFDirection flag. It sets the direction of the string verbs.

Adverbs (1) · A prefix, for example REP: do the next verb again, CX times.

WordMeaningExample
REPDo the next string verb again, CX times.rep stosb

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-C1 critical FORTRAN 77 has no array syntax. Whole-array expressions and slices came in Fortran 90. 8086 to 486 CPUs have no SIMD, thus the compiler has nothing to auto-vectorize. MMX came in 1997, and x87 is scalar. The primary Fortran advantages in the document do not exist on its own target.
  • D01-M4 major The claim is too strong. The standard gives the rule to the programmer, and compilers do not check it. POINTER/TARGET arguments can alias. A violation gives silent wrong results, and that is itself a pedagogical hazard.
  • D01-m2 minor "Column-major storage ensures contiguous sweeps". This is true only if the loop order matches (the innermost loop runs on the first index). Beginners often get this wrong.
  • D14-C2 critical The video says the opposite. At 28:34 the five unused sprites of each coin already point to transparent tile zero. The PPU "still counts those transparent sprites" toward the 32 per line, so tile zero is the problem. The fix moves a tile-zero sprite "down to an offscreen value" (28:55). At 30:08 Inkbox says that registers exist to rotate sprites in OAM, but he decides to "leave it as is for now". At 30:55 he says that the objects are "not organized by X or Y". The value "Y = 224" in image 3 is not in the video.
  • D14-M9 major The limit is 32 sprites per line and also 34 slivers of 8 pixels per line (29:38 to 29:59). With 16 x 16 sprites, 24 objects plus the player give 48 slivers, so only 17 objects drew. The document omits the sliver rule, which was the real cause of the lost player sprite.