An 8086 program has very little working space: a handful of registers and a memory divided into segments. Once you can picture those two things, every later instruction makes more sense. This tutorial assumes you have Emu8086 running; the install guide covers setup, and the Hello World tutorial covers your first run.
The general-purpose registers
AX, BX, CX and DX are the workhorses. Each is 16 bits wide, and each splits into a high and a low byte: AH and AL for AX, BH and BL for BX, and so on. Writing to AL changes only the low byte of AX; the high byte is untouched. That split is a frequent source of beginner bugs, so check the register window after every step when you are learning.
Pointers and index registers
SI and DI are index registers, most often used to walk through arrays and strings. SP points to the top of the stack and BP is used to reach values stored on the stack. IP, the instruction pointer, is not something you set directly in normal code; it simply follows the instruction being executed, and jumps change it for you.
Segment registers
Memory is addressed as a segment plus an offset. CS holds the code segment, DS the data segment, SS the stack segment and ES an extra segment. In a tiny .COM program all four usually point at the same segment, which is why beginners can ignore them at first. In a .EXE program you set DS yourself, as shown in the .COM vs .EXE guide.
A small example to step through
Run this program with single-stepping and watch AX, BX and CX after each instruction. The point is not the result; it is seeing how a value moves from one register to another and how a byte move leaves the other half of a register alone.
ORG 100h MOV AX, 1234h MOV BX, AX MOV AL, 56h MOV CX, BX RET
What you should see
After the first two instructions, AX and BX should both hold 1234h. After MOV AL, 56h, AX should read 1256h: the low byte changed to 56h while the high byte stayed 12h. CX ends up holding the old BX value, 1234h, because it was copied before AL was changed. If your register window shows something else, you probably stepped past an instruction or edited a value by accident; reload and step again.
A habit worth building
- Step every new program once, slowly, before running it at full speed.
- Check the flags as well as the registers when a comparison or an arithmetic instruction is involved.
- When a value looks wrong, ask which half of the register you actually changed.
Next steps
Next, MOV, ADD and SUB put these registers to work, and arrays and strings show SI and DI in action. Keep the opcode reference open while you practise, and return to the home page for the full tutorial list.
