- Data Transfer Instructions
- Arithmetic Instructions
- Logical Instructions
- Branch Instructions
- Stack Operations
- Control Instructions
- Special Instructions
Syntax:
MOV destination, sourceDescription: Copies the contents of the source register/memory to the destination register/memory.
| Example | Description |
|---|---|
MOV A, B |
Copy contents of B to A |
MOV M, A |
Store A into memory at (HL) |
Syntax:
MVI register, data8
MVI M, data8Description: Loads an 8-bit immediate value into a register or memory.
| Example | Description |
|---|---|
MVI A, #1F |
Load 1F (hex) into A |
MVI M, #05 |
Store 05 (hex) at memory (HL) |
Syntax:
LXI rp, data16Description: Loads a 16-bit immediate value into a register pair (B, D, H, or SP).
| Example | Description |
|---|---|
LXI H, #9000 |
HL = 9000H |
LXI SP, #FF00 |
SP = FF00H |
Syntax:
LDA address16
STA address16Description:
LDA: Loads accumulator from memory address.STA: Stores accumulator to memory address.
| Example | Description |
|---|---|
LDA #9000 |
A = [9000H] |
STA #9002 |
[9002H] = A |
Syntax:
LHLD address16
SHLD address16Description:
LHLD: Loads HL pair from two consecutive memory locations.SHLD: Stores HL pair to two consecutive memory locations.
| Example | Description |
|---|---|
LHLD #9000 |
HL = [9000H] + [9001H] |
SHLD #9100 |
[9100H] = L, [9101H] = H |
Syntax:
ADD source
ADI data8Description: Adds the source register/memory or immediate value to the accumulator (A).
| Example | Description |
|---|---|
ADD B |
A = A + B |
ADD M |
A = A + [HL] |
ADI #10 |
A = A + 10H |
Syntax:
ADC sourceDescription: Adds source and carry flag to accumulator.
| Example | Description |
|---|---|
ADC C |
A = A + C + CY |
Syntax:
SUB source
SUI data8Description: Subtracts source register/memory or immediate value from accumulator.
| Example | Description |
|---|---|
SUB D |
A = A - D |
SUI #05 |
A = A - 05H |
Syntax:
SBB sourceDescription: Subtracts source and borrow (carry flag) from accumulator.
| Example | Description |
|---|---|
SBB E |
A = A - E - CY |
Syntax:
INR destination
DCR destinationDescription: Increments or decrements the specified register or memory by 1.
| Example | Description |
|---|---|
INR B |
B = B + 1 |
DCR M |
[HL] = [HL] - 1 |
Syntax:
ANA sourceDescription: Logical AND between accumulator and source.
| Example | Description |
|---|---|
ANA H |
A = A & H |
Syntax:
ORA sourceDescription: Logical OR between accumulator and source.
| Example | Description |
|---|---|
ORA L |
A = A |
Syntax:
XRA sourceDescription: Logical XOR between accumulator and source.
| Example | Description |
|---|---|
XRA M |
A = A ^ [HL] |
Syntax:
CMADescription: Complements (bitwise NOT) the accumulator.
| Example | Description |
|---|---|
CMA |
A = ~A |
Syntax:
CMP source
CPI data8Description: Compares source or immediate with accumulator (sets flags, does not change A).
| Example | Description |
|---|---|
CMP B |
Compare B with A |
CPI #20 |
Compare 20H with A |
Syntax:
JMP address16Description: Sets PC to address.
| Example | Description |
|---|---|
JMP #8000 |
Jump to address 8000H |
Syntax:
JZ address16 ; Jump if Zero flag set
JNZ address16 ; Jump if Zero flag not set
JC address16 ; Jump if Carry flag set
JNC address16 ; Jump if Carry flag not setDescription: Jumps to address if condition is met.
| Example | Description |
|---|---|
JZ #8010 |
Jump to 8010H if Zero flag is set |
JNC #8020 |
Jump to 8020H if Carry not set |
Syntax:
CALL address16
RETDescription:
CALL: Pushes PC to stack, jumps to address.RET: Pops address from stack to PC.
| Example | Description |
|---|---|
CALL #9000 |
Call subroutine at 9000H |
RET |
Return from subroutine |
Syntax:
PUSH rp
POP rpDescription:
PUSH: Pushes register pair onto stack.POP: Pops two bytes from stack into register pair.
| Example | Description |
|---|---|
PUSH B |
Push BC onto stack |
POP H |
Pop two bytes into HL |
Syntax:
HLTDescription: Halts program execution.
| Example | Description |
|---|---|
HLT |
Stop execution |
Syntax:
NOPDescription: Does nothing (1 machine cycle).
| Example | Description |
|---|---|
NOP |
No operation |
Syntax:
DAADescription: Adjusts A for BCD addition.
Syntax:
STC
CMCDescription:
STC: Sets carry flag.CMC: Complements carry flag.
Syntax:
EI
DIDescription:
EI: Enable interrupts.DI: Disable interrupts.
Syntax:
RIM
SIMDescription:
RIM: Read interrupt mask.SIM: Set interrupt mask.
Syntax:
RLC ; Rotate accumulator left
RRC ; Rotate accumulator right
RAL ; Rotate accumulator left through carry
RAR ; Rotate accumulator right through carryDescription: Rotates bits in accumulator (A) as described.
MVI A, #05 ; Load 05H into A
MVI B, #03 ; Load 03H into B
ADD B ; A = A + B (A = 08H)
STA #9000 ; Store result at 9000H
HLT ; Halt