8088 Assembly Language in a Nutshell
The Glorious History of the 8088
Ah, the late 1970s—a time when disco was king, and Intel decided to shake up the microprocessor world with the 8086.
But wait!!, there’s more!
In 1979, they introduced the 8088, a cost-effective version with an 8-bit external data bus.
This little tweak made it the perfect brain for the original IBM PC, and the rest, as they say, is history.
The 8088 was the bridge between 8-bit and 16-bit computing, making it a versatile choice for early personal computers.
Its architecture laid the groundwork for the x86 platform, which still dominates the PC market today.
(And modern Intel CPUS STILL support 8088 instructions!)
8088 Architecture - What’s Inside?
The Intel 8088 is like the Swiss Army knife of microprocessors. Here’s a peek under the hood:
Registers:
- General Purpose Registers: AX, BX, CX, DX (each can be split into high and low bytes, e.g., AH and AL).
- Index Registers: SI (Source Index), DI (Destination Index).
- Pointer Registers: BP (Base Pointer), SP (Stack Pointer).
- Instruction Pointer: IP (points to the next instruction).
- Segment Registers: CS (Code Segment), DS (Data Segment), SS (Stack Segment), ES (Extra Segment).
- Flags Register: Reflects the outcome of operations (zero, carry, sign, etc.).
Memory Addressing:
- 20-bit address bus, allowing access to a whopping 1 MB of memory. That’s right, folks, 1 megabyte!
Clock Speed:
- Typically around 4.77 MHz in the original IBM PC. Blazing fast for its time!
8088 Instruction Set
Mnemonic | Description |
---|---|
MOV | Move data |
ADD | Add |
SUB | Subtract |
INC | Increment |
DEC | Decrement |
MUL | Unsigned multiply |
DIV | Unsigned divide |
AND | Logical AND |
OR | Logical OR |
XOR | Logical exclusive OR |
NOT | Logical NOT |
JMP | Unconditional jump |
CALL | Call procedure |
RET | Return from procedure |
PUSH | Push onto stack |
POP | Pop from stack |
NOP | No operation (does nothing) |
HLT | Halt the processor |
For all the 8088 instructions, check out the x86 instruction listings
Example Code
1. Hello World over RS-232
|
|
2. Blinking an LED
|
|
Bubble Sort
A Bubble sort is a simple sorting algorithm that repeatedly steps through an array, swapping adjacent elements if they are in the wrong order.
This process repeats until the array is sorted.
8088 Assembly Bubble Sort
|
|
Explanation
The routine expects the DS:SI registers to point to the start of the array.
The count of elements in the array should be in the CX register.
Outer Loop:
The outer loop runs n-1 times (n is the number of elements), since a single pass ensures the largest unsorted element bubbles to its correct position.
Inner Loop:
Adjacent elements are compared.
If a pair is out of order (the current element is greater than the next), they are swapped.
The xchg instruction is used for swapping values.
Pointers and Counters:
DI serves as a pointer to the current element in the array.
BX keeps track of the number of comparisons per pass, which decreases as the largest elements settle into their final positions.
Notes
- This implementation assumes the array consists of 16-bit integers (WORD size). Adjustments are necessary for different data sizes.
- Ensure that the segment registers (DS) are correctly set to point to the data segment containing the array before calling this routine.
- The xchg instruction is used here , but depending on your assembler, you might need to implement the swap manually using mov instructions.