8051 and 8086 Cheat Sheet:
8051 Microcontroller
Function
The 8051 is used for controlling embedded systems. It integrates CPU, memory, I/O ports, timers, and serial communication on a single chip. Commonly used in automation, robotics, and real-time control systems.
| Feature | Details |
|---|---|
| Type | 8-bit Microcontroller |
| Architecture | Harvard Architecture |
| Memory | 4KB ROM, 128B RAM |
| I/O Ports | 4 Ports (P0–P3) |
| Timers | 2 Timers |
| Interrupts | 5 Interrupts |
Important Instructions & Functions
| Instruction | Function |
|---|---|
| MOV A, B | Copies data from B to A |
| ADD A, R1 | Adds register R1 to accumulator |
| SUBB A, R2 | Subtract with borrow |
| INC A | Increment accumulator by 1 |
| DEC R0 | Decrement register |
| ANL A, #data | Bitwise AND |
| ORL A, #data | Bitwise OR |
| XRL A, #data | Bitwise XOR |
| SJMP label | Short jump (within range) |
| LJMP addr | Long jump anywhere in memory |
| DJNZ R1, label | Decrement and jump if not zero |
| CJNE A, #data, label | Compare and jump if not equal |
8051 Microcontroller Logical Instructions
1. CPL — Complement
CPL means invert all bits (NOT operation).
Syntax
CPL A
This flips every bit in accumulator A.
Example
Before:
A = 01010101
After:
A = 10101010
Bit Version
CPL P1.0
Changes:
- 0 → 1
- 1 → 0
for pin/bit P1.0.
2. ANL — AND Logical
Performs bitwise AND operation.
Syntax
ANL A,#0FH
Example
A = 10101100
0FH = 00001111
----------------
Result = 00001100
Stored back into A.
Common Use
Masking bits.
ANL A,#0F0H
Keeps upper 4 bits, clears lower 4 bits.
3. ORL — OR Logical
Performs bitwise OR operation.
Syntax
ORL A,#0FH
Example
A = 10100000
0FH = 00001111
----------------
Result = 10101111
Common Use
Setting bits to 1.
4. XRL — Exclusive OR Logical (XOR)
Performs XOR operation.
Syntax
XRL A,#0FFH
Example
A = 10101010
0FFH = 11111111
----------------
Result = 01010101
Common Use
- Toggle bits
- Encryption
- Bit comparison
Address Changes / Memory Effect
These instructions modify the destination operand.
Example 1 — Register Change
MOV A,#55H
CPL A
Before:
A = 55H
After:
A = AAH
No memory address changes — only accumulator changes.
Example 2 — RAM Address Change
ANL 30H,#0FH
This modifies RAM location 30H.
Before:
RAM[30H] = 3CH
Binary:
00111100
AND
00001111
---------
00001100
After:
RAM[30H] = 0CH
So the contents at address 30H change.
Summary Table
| Instruction | Meaning | Operation |
|---|---|---|
| CPL | Complement | NOT |
| ANL | AND Logical | AND |
| ORL | OR Logical | OR |
| XRL | Exclusive OR Logical | XOR |
Boolean Symbols
| Instruction | Symbol |
|---|---|
| CPL | ¬A |
| ANL | A · B |
| ORL | A + B |
| XRL | A ⊕ B |
Example Program
MOV A,#55H
ORL A,#0FH
XRL A,#0FFH
CPL A
Step-by-Step
55H = 01010101
ORL -> 01011111
XRL -> 10100000
CPL -> 01011111
Final Result
A = 5FH
8086 Microprocessor
Function
The 8086 is a general-purpose microprocessor used for executing programs. It separates execution into Bus Interface Unit (BIU) and Execution Unit (EU), enabling instruction pipelining and faster processing.
| Feature | Details |
|---|---|
| Type | 16-bit Microprocessor |
| Address Bus | 20-bit (1 MB memory) |
| Instruction Queue | 6-byte prefetch queue |
| Segments | CS, DS, SS, ES |
Important Instructions & Functions
| Instruction | Function |
|---|---|
| MOV AX, BX | Transfers data from BX to AX |
| ADD AX, BX | Adds BX to AX |
| SUB AX, BX | Subtracts BX from AX |
| MUL BX | Unsigned multiplication |
| DIV BX | Division |
| INC AX | Increment AX |
| DEC BX | Decrement BX |
| AND AX, BX | Bitwise AND |
| OR AX, BX | Bitwise OR |
| XOR AX, BX | Bitwise XOR |
| JMP label | Unconditional jump |
| JZ label | Jump if zero flag = 1 |
| JNZ label | Jump if zero flag = 0 |
| CALL addr | Call procedure |
| RET | Return from procedure |
8051 vs 8086
| Feature | 8051 | 8086 |
|---|---|---|
| Main Function | Control hardware (embedded) | Execute programs |
| Type | Microcontroller | Microprocessor |
| Data Width | 8-bit | 16-bit |
| Architecture | Harvard | Von Neumann |
| Usage | Embedded systems | General computing |