8085 Instruction Set: Examples and Solutions
Arithmetic Operations
1. ADD: Adds the contents of a register or memory to the accumulator.
Example:
MVI A, 05H ; Load 5 into accumulator
MVI B, 03H ; Load 3 into register B
ADD B ; Add B to A
Result: A = 08H
2. SUB: Subtracts the contents of a register or memory from the accumulator.
Example:
MVI A, 0AH ; Load 10 into accumulator
MVI B, 02H ; Load 2 into register B
SUB B ; Subtract B from A
Result: A = 08H
3. DAD: Adds the contents of a register pair to HL.
Example:
LXI H, 1234H ; Load HL with 1234H
LXI D, 1111H ; Load DE with 1111H
DAD D ; Add DE to HL
Result: HL = 2345H
Logical Operations
1. ANA: Logical AND operation with the accumulator.
Example:
MVI A, 0F0H ; Load A with F0H
ANI 0FH ; AND A with 0FH
Result: A = 00H
2. ORA: Logical OR operation with the accumulator.
Example:
MVI A, 0F0H ; Load A with F0H
ORI 0F ; OR A with 0FH
Result: A = FFH
3. CMA: Complements the accumulator.
Example:
MVI A, 55H ; Load A with 55H
CMA ; Complement A
Result: A = AAH
Data Transfer Instructions
1. MOV: Transfer data between registers.
Example:
MVI A, 0FH ; Load A with 0FH
MOV B, A ; Move A to B
Result: B = 0FH
2. LDA: Load data from memory to the accumulator.
Example:
LDA 2000H ; Load data from memory location 2000H into A
Result: A = Content of 2000H
3. STA: Store data from the accumulator to memory.
Example:
MVI A, 0AH ; Load A with 0AH
STA 3000H ; Store A into memory location 3000H
Branching and Looping
1. JMP: Unconditional jump to a memory address.
Example:
JMP 2500H ; Jump to address 2500H
2. JC: Jump if carry flag is set.
Example:
MVI A, 0FFH ; Load A with FFH
ADD A ; Add A to itself, generating a carry
JC 3000H ; Jump to address 3000H if carry is set
3. Looping: Using JMP for repeated operations.
Example:
MVI C, 05H ; Load counter with 5
LOOP: DCR C ; Decrement counter
JNZ LOOP ; Jump back to LOOP if Z flag is not set