Skip to content

A side: Keeping 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 tell the machine to remember a number?

26 Assembly words in this segment
19 Fortran words for the same job

What Assembly says well here

  • You choose the exact place for each value: a register inside the processor, or an address in memory.
  • You control every byte. A complete DOS program can be smaller than 1 KB.
  • A segment register (DS, ES, CS, SS) selects a window of 64 KB. A small .COM program keeps all four on one value, so it lives in one window.

What is hard to say

  • The 8086 has only eight general registers. You must remember what each one holds.
  • A value has no type. A byte is only a number until your code gives it a meaning.
  • An address is the segment times 16 plus the offset. Segments overlap every 16 bytes, so one byte has 4,096 names: A000:0000 is also 9FFF:0010. A SNES bank is one byte of the address, and banks do not overlap. The idea is the same, but the arithmetic is not.

One sentence in Assembly

mov ax, 100

It says: Put the number 100 in register AX.

The words, by part of speech

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

WordMeaningExample
MOVCopy a value from one place to a different place.mov ax, 5
XCHGSwap the values in two places.xchg ax, bx
PUSHPut a value on the top of the stack.push ax
POPTake the value from the top of the stack.pop ax
LEACalculate an address and keep the address. It does not read the memory.lea si, [bx+4]
XLATTable lookup: replace AL with the byte at [BX + AL]. One verb reads one entry of a table.mov bx, speeds xlat

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

WordMeaningExample
AXRegister A, the primary work register (16 bits). AH and AL are its two halves.mov ax, 0
BXRegister B. It often holds a memory address.mov al, [bx]
CXRegister C, the counter. LOOP and REP count down with it.mov cx, 10
DXRegister D. It holds the high half of large results, and port numbers.mov dx, 3DAh
SISource index. It points to the place where data comes from.mov si, map
DIDestination index. It points to the place where data goes.xor di, di
BPBase pointer. It points into the stack.mov bp, sp
SPStack pointer. It points to the top of the stack.
DSData segment. It selects the 64 KB area that holds the data.
ESExtra segment. It selects a second area, for example the screen memory.mov es, ax
CSCode segment. It selects the area that holds the instructions.
SSStack segment. It selects the area that holds the stack.
stackA pile of values in memory. The last value in is the first value out.push ax

Adjectives (2) · A size word, for example BYTE (8 bits) or WORD (16 bits).

WordMeaningExample
BYTESize: 8 bits, one value from 0 to 255.mov byte [bx], 7
WORDSize: 16 bits, one value from 0 to 65,535.mov word [score], 0

Grammar marks (1) · Commas between operands, [square brackets] for memory, a colon after a label.

WordMeaningExample
[ ]Square brackets mean "the value at this address", not the address.mov al, [bx]

Note to the translators (4) · An assembler directive, for example ORG, DB or %macro.

WordMeaningExample
DBDefine bytes. Put these bytes in the program file.msg db 'Hello$'
DWDefine words. Put these 16-bit numbers in the program file.score dw 0
RESBReserve bytes. Keep this much empty space.buffer resb 64000
EQUGive a name to a number.WIDTH equ 320

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-M4 major These are 16-bit registers. 16.16 math needs 32-bit registers (EAX and the others, 386 and later) or register pairs on the 8086. REP MOVSD (L31) also needs a 386 or later. The document mixes 8086 and 386 targets and does not say so.
  • D13-M4 major The video names neither LoROM nor HiROM, and it does not discuss fast or slow ROM. Its memory lesson is the data bank register: ROM from bank $C0, code in the second half of each bank, so the mirror reaches the hardware registers and "the first 8K of low RAM" (20:35 to 21:59). It moved the objects from bank $7F to the first RAM bank to avoid bank switches. The document misses this lesson, which is the closest SNES parallel to the 8086 segment registers.