Microprocessor and Computer ArchitectureUnit 312 min read
8085 Instruction Set & Addressing Modes: Types, Examples & Real-World Use
Unit 3 of Microprocessor and Computer Architecture covers the 8085 microprocessor’s instruction set classification (data transfer, arithmetic, logic, branch, stack, I/O, machine control) and its six addressing modes (immediate, register, direct, register indirect, implied, and extended). This note explains each instruc
1. Instruction Set of 8085: Classification and Examples
The 8085 instruction set consists of 244 instructions categorized into 8 groups based on functionality. Each instruction performs a specific operation on data or controls program flow.
1.1 Classification of Instructions
The 8085 instructions are divided into the following categories:
| Category | Function | Example Instructions |
|---|---|---|
| Data Transfer | Move data between registers, memory, and I/O ports. | MOV, MVI, LDA, STA, LXI, XCHG |
| Arithmetic | Perform addition, subtraction, increment, decrement, and arithmetic shifts. | ADD, SUB, INR, DCR, DAD |
| Logic | Perform bitwise AND, OR, XOR, complement, and rotate operations. | ANA, ORA, XRA, CMA, RLC |
| Branch (Jump/Conditional) | Alter program flow based on conditions or unconditionally. | JMP, CALL, RET, JNZ, JC |
| Stack, Pop, Push | Manage stack operations (LIFO). | PUSH, POP, XTHL, SPHL |
| I/O Instructions | Transfer data between CPU and I/O devices. | IN, OUT |
| Machine Control | Halt, disable interrupts, enable interrupts, and reset operations. | HLT, NOP, DI, EI, RIM, SIM |
| Rotate & Shift | Rotate or shift bits within registers or memory. | RLC, RRC, RAL, RAR, RAL, RAR |
1.2 Worked Example: Data Transfer Instructions
Instruction: MOV B, A
- Mnemonic: Move data from register A to register B.
- Opcode:
47H - Operation:
- The content of A is copied to B.
- The source register (A) remains unchanged.
- Flags affected: None.
Example Trace:
If (A) = 37H and (B) = 57H, after MOV B, A:
(A) = 37H(unchanged)(B) = 37H(copied from A)
1.3 Worked Example: Arithmetic Instruction (ADD B)
Instruction: ADD B
- Mnemonic: Add content of B to A.
- Opcode:
80H - Operation:
(A) = (A) + (B)- Flags affected: S (Sign), Z (Zero), C (Carry), P (Parity), AC (Auxiliary Carry).
Example Trace:
If (A) = 37H and (B) = 57H:
- Binary addition:
A: 0011 0111 (55) B: 0101 0111 (87) Sum: 1000 1110 (142) - Result:
(A) = 8EH(142 in decimal) - Flags:
- S = 1 (MSB is 1, negative in 8-bit signed)
- Z = 0 (Result ≠ 0)
- C = 1 (Carry generated)
- P = 0 (Even parity)
- AC = 1 (Auxiliary carry from bit 3 to 4)
2. Addressing Modes of 8085
Addressing modes determine how the operand is specified in an instruction. The 8085 supports six addressing modes:
| Addressing Mode | Description | Example Instruction | Operand Format |
|---|---|---|---|
| Immediate | Operand is part of the instruction (literal value). | MVI A, 32H |
32H (8-bit) |
| Register | Operand is a register (A, B, C, D, E, H, L). | MOV B, A |
A (source), B (dest) |
| Direct | Operand is a memory location (16-bit address). | STA 2100H |
2100H (memory address) |
| Register Indirect | Operand is in memory, address stored in H-L pair. | MOV A, M |
M (memory pointed by HL) |
| Implied | Operand is implied (no operand specified). | INR A |
None |
| Extended | Used for JMP and CALL (16-bit address). | JMP 3000H |
3000H (16-bit address) |
2.1 Worked Example: Immediate Addressing (MVI A, 32H)
Instruction: MVI A, 32H
- Mnemonic: Move immediate value
32Hto A. - Opcode:
3EH(forMVI A, data) - Operation:
- The 8-bit literal
32His loaded into A. - Flags affected: None.
- The 8-bit literal
Example Trace:
- Before:
(A) = ?(unknown) - After:
(A) = 32H(50 in decimal)
2.2 Worked Example: Direct Addressing (STA 2100H)
Instruction: STA 2100H
- Mnemonic: Store A into memory location
2100H. - Opcode:
32H(forSTA addr) - Operation:
- The 16-bit address
2100His specified. - The content of A is written to
2100H. - Flags affected: None.
- The 16-bit address
Example Trace:
- If
(A) = 45Hand(2100H) = ?(unknown):- After
STA 2100H:(2100H) = 45H
- After
2.3 Worked Example: Register Indirect (MOV A, M)
Instruction: MOV A, M
- Mnemonic: Move data from memory (pointed by H-L) to A.
- Opcode:
7EH - Operation:
- The 16-bit address in H-L is used to fetch data.
- Data at
(HL)is copied to A. - Flags affected: None.
Example Trace:
- If
(H) = 20H,(L) = 00H→(HL) = 2000H - If
(2000H) = 67Hand(A) = ?:- After
MOV A, M:(A) = 67H,(2000H)remains unchanged.
- After
3. Real-World Applications of 8085 Instructions & Addressing Modes
3.1 eSewa (Nepal) – Transaction Processing
- Instruction Used:
ADD,SUB,STA(Direct Addressing) - How?
- When a user pays an electricity bill via eSewa, the 8085-like processor (or modern equivalent) in the backend system:
- Fetches the user’s balance (
LDA 3000H– Direct Addressing). - Subtracts the bill amount (
SUB 20H– Immediate Addressing). - Stores the updated balance (
STA 3000H– Direct Addressing).
- Fetches the user’s balance (
- Addressing Mode: Direct (for memory access) and Immediate (for fixed bill amount).
- When a user pays an electricity bill via eSewa, the 8085-like processor (or modern equivalent) in the backend system:
3.2 Daraz (Nepal) – Order Queue Management
- Instruction Used:
MOV,INR,JNZ(Register & Implied Addressing) - How?
- Daraz’s order processing system (simplified for 8085 logic):
- Initializes an order counter (
MVI B, 00H– Immediate). - Loops through orders (
INR B– Implied, increments counter). - Checks if orders are processed (
CMP 10H– Immediate, compares with max orders). - Jumps back if not done (
JNZ LOOP– Conditional Jump).
- Initializes an order counter (
- Addressing Mode: Implied (for
INR B) and Immediate (for fixed values).
- Daraz’s order processing system (simplified for 8085 logic):
3.3 Ncell (Nepal) – SMS Delivery System
- Instruction Used:
LXI,MOV,OUT(Register Indirect & I/O) - How?
- When an SMS is sent via Ncell:
- Loads the SMS data into H-L (
LXI H, 4000H– Register Indirect). - Moves data to a buffer (
MOV A, M– Register Indirect). - Sends via I/O port (
OUT 03H– I/O Addressing).
- Loads the SMS data into H-L (
- Addressing Mode: Register Indirect (for memory access) and I/O (for modem communication).
- When an SMS is sent via Ncell:
4. Comparison of Addressing Modes
| Feature | Immediate | Register | Direct | Register Indirect | Implied | Extended |
|---|---|---|---|---|---|---|
| Operand Location | Inside instruction | Register | Memory (16-bit) | Memory (via H-L) | None | Memory (16-bit) |
| Speed | Fastest | Fast | Medium | Medium | Fastest | Slowest |
| Flexibility | Low (fixed value) | High | Medium | High | Low | Medium |
| Example Instruction | MVI A, 32H |
MOV B, A |
STA 2100H |
MOV A, M |
INR A |
JMP 3000H |
| Use Case | Loading constants | Fast register ops | Memory access | Stack/array operations | Auto-increment | Jumps/Calls |
5. Instruction Execution: Worked Example (Full Trace)
Problem:
Write the 8085 assembly program to add two numbers stored at 2000H and 2001H, store the result at 2002H, and check if the result is zero.
Solution:
LDA 2000H ; Load first number (Direct Addressing)
ADD 2001H ; Add second number (Direct Addressing)
STA 2002H ; Store result (Direct Addressing)
JNZ NOT_ZERO ; Jump if result ≠ 0 (Conditional Jump)
HLT ; Halt if result = 0
NOT_ZERO: HLT
Step-by-Step Trace:
LDA 2000H(A) = (2000H)(e.g.,35H)- Flags: Updated (S, Z, P, etc.)
ADD 2001H(A) = (A) + (2001H)(e.g.,35H + 4AH = 7FH)- Flags: Updated (C=0, Z=0, S=0, P=1)
STA 2002H(2002H) = (A) = 7FH
JNZ NOT_ZERO- Since
Z=0, jump toNOT_ZERO. - If
(A) = 00H,Z=1, so no jump (halt).
- Since
6. Exam Tip: How to Score Full Marks
Define Clearly:
- Always start with definitions (e.g., "Addressing mode is a technique to specify the operand in an instruction.").
- Example:
"Immediate addressing is an addressing mode where the operand is part of the instruction itself."
Use Examples:
- For every instruction, provide:
- Opcode (if asked).
- Operation (what it does).
- Flags affected (if any).
- Example for
ADD B:"The
ADD Binstruction adds the content of register B to A. The opcode is80H. Flags affected: S, Z, C, P, AC."
- For every instruction, provide:
Trace Execution:
- For programs, show step-by-step register/memory changes.
- Example:
"After
MOV B, A, if(A)=37H, then(B)=37H."
Compare Addressing Modes:
- Use a table to compare speed, flexibility, and use cases.
- Example:
"Immediate addressing is fastest but least flexible, while register indirect is slower but more flexible for arrays."
Link to Real-World:
- In short-answer questions, relate instructions to eSewa, Daraz, or Ncell.
- Example:
"The
STAinstruction (Direct Addressing) is used in eSewa to update a user’s balance in memory."
Avoid Common Mistakes:
- ❌ Don’t assume flags are affected unless specified (e.g.,
MOVdoes not affect flags). - ❌ Don’t mix up 8-bit and 16-bit operations (e.g.,
DADis 16-bit,ADDis 8-bit). - ❌ Don’t forget to initialize registers before use (e.g.,
MVI B, 00H).
- ❌ Don’t assume flags are affected unless specified (e.g.,
Final Checklist for Exam:
✅ Define the instruction/addressing mode. ✅ Give an example with opcode (if asked). ✅ Trace execution (register/memory changes). ✅ Mention flags affected (if any). ✅ Compare with other modes (if comparison is asked). ✅ Relate to real-world (eSewa, Daraz, Ncell).
Based on the TU BCA syllabus for Microprocessor and Computer Architecture (CACS155), unit 3.
Discussion
Loading…