A side: Keeping values

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, 100It 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.
| Word | Meaning | Example |
|---|---|---|
| MOV | Copy a value from one place to a different place. | mov ax, 5 |
| XCHG | Swap the values in two places. | xchg ax, bx |
| PUSH | Put a value on the top of the stack. | push ax |
| POP | Take the value from the top of the stack. | pop ax |
| LEA | Calculate an address and keep the address. It does not read the memory. | lea si, [bx+4] |
| XLAT | Table 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.
| Word | Meaning | Example |
|---|---|---|
| AX | Register A, the primary work register (16 bits). AH and AL are its two halves. | mov ax, 0 |
| BX | Register B. It often holds a memory address. | mov al, [bx] |
| CX | Register C, the counter. LOOP and REP count down with it. | mov cx, 10 |
| DX | Register D. It holds the high half of large results, and port numbers. | mov dx, 3DAh |
| SI | Source index. It points to the place where data comes from. | mov si, map |
| DI | Destination index. It points to the place where data goes. | xor di, di |
| BP | Base pointer. It points into the stack. | mov bp, sp |
| SP | Stack pointer. It points to the top of the stack. | |
| DS | Data segment. It selects the 64 KB area that holds the data. | |
| ES | Extra segment. It selects a second area, for example the screen memory. | mov es, ax |
| CS | Code segment. It selects the area that holds the instructions. | |
| SS | Stack segment. It selects the area that holds the stack. | |
| stack | A 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).
| Word | Meaning | Example |
|---|---|---|
| BYTE | Size: 8 bits, one value from 0 to 255. | mov byte [bx], 7 |
| WORD | Size: 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.
| Word | Meaning | Example |
|---|---|---|
| [ ] | 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.
| Word | Meaning | Example |
|---|---|---|
| DB | Define bytes. Put these bytes in the program file. | msg db 'Hello$' |
| DW | Define words. Put these 16-bit numbers in the program file. | score dw 0 |
| RESB | Reserve bytes. Keep this much empty space. | buffer resb 64000 |
| EQU | Give 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.