8086 Assembly Language
Program the processor itself in 8086 assembly, watching every register and flag change: MOV and the data segment, arithmetic and the flags, DOS input and output, comparisons and jumps, loops, MUL and DIV, bits and shifts, arrays and addressing modes, the stack, procedures and strings.
- 1
Your first 8086 program
What the 8086 is, the shape every program has (.MODEL, .DATA, .CODE and MAIN PROC), and how a program prints a character and a message with INT 21h.
- 2
Registers and MOV
The 8086's registers and what each is for, numbers in hex and binary, and MOV, the instruction that copies a value, with the rules it must follow.
- 3
Variables and the data segment
Defining bytes, words, strings and arrays with DB, DW, DUP, ? and EQU; where each variable sits in memory; why words are stored low byte first; and the difference between a variable's address and its value.
- 4
Arithmetic and the flags
ADD, SUB, INC, DEC and NEG, and the flags every result sets: carry, zero, sign, overflow, parity. The same bits read as unsigned or signed numbers, and ADC for numbers bigger than 16 bits.
- 5
Keyboard and screen with INT 21h
Reading a key and a whole line, printing characters, strings and new lines, and turning the digit a user types into the number it stands for (and back).
- 6
Comparing and jumping
CMP and the conditional jumps that read its flags, signed and unsigned comparisons, and how if and if-else are written with labels.
- 7
Loops
Counting loops with LOOP and CX, while-loops built from CMP and jumps, guarding against CX = 0, and nested loops that save CX on the stack.
- 8
Multiplication and division Intermediate
MUL and DIV with their fixed registers (AX, and DX:AX for words), IMUL and IDIV for signed numbers, the divide overflow, and printing a number of any size by dividing by 10.
- 9
Bits: logic, shifts and rotates Intermediate
AND, OR, XOR, NOT and TEST with masks, turning letters to upper or lower case, SHL and SHR as fast multiply and divide by 2, rotates, and printing a number in binary.
- 10
Arrays and addressing modes Intermediate
Every way an 8086 instruction can name its operand: immediate, register, direct, register indirect, based, indexed and based-indexed; walking byte and word arrays; and the sum and the largest value of an array.
- 11
The stack Intermediate
How the stack works (SS, SP, PUSH and POP, last in first out), saving registers, reversing a string, and why every PUSH needs its POP.
- 12
Procedures: CALL and RET Intermediate
Writing procedures with PROC and ENDP, how CALL and RET use the stack for the return address, passing values in registers and on the stack, saving registers, and recursion.
- 13
String instructions Intermediate
MOVSB, LODSB, STOSB, CMPSB and SCASB, which work through memory with SI and DI by themselves; repeating them with REP, REPE and REPNE; the direction flag; and setting ES.