8085
Instructions
The instruction set of the 8085 microprocessor forms the foundation of any program
written for this microprocessor. Understanding the different instructions and how they
work is crucial for writing efficient assembly language programs that control hardware,
perform computations, and handle data effectively.
Assembly Language: Low-level programming language using mnemonics (e.g., MOV
AX, 5).
Machine Language: Binary code directly executed by the microprocessor (e.g.,
10110000 00000101).
Mnemonics: Human-readable symbols in assembly language (e.g., MOV, ADD).
Example: MOV AX, 5 ; Move the value 5 into register AX
Let's consider a simple task: adding two MOV BX, 3 ; Move the value 3 into register BX
numbers. ADD AX, BX ; Add the value in BX to AX (AX = AX
Task: Add 5 and 3, and store the + BX)
result.
8085 Instructions
Each instruction has two parts.
• Since the 8085 is an 8-bit device it can The first part is the task or operation to be
have up to 256 instructions. performed.
This part is called the “opcode” (operation
• However, the 8085 only uses 246 code).
combinations that represent a total of
74 instructions. The second part is the data to be operated on.
Called “operand”.
• These instructions can be grouped into
five different groups:
• Data Transfer Operations
• Arithmetic Operations
• Logic Operations
• Branch Operations
• Machine Control Operations
How machine reads ???
Example: MOV C, A Example: ADD B
Instructions are classified based on their byte size:
1-Byte Instructions
These instructions use only one byte. The opcode (operation
code) itself specifies the instruction and the register or memory
location involved.
Examples:
• MOV A, B: Move the content of register B to register A.
• ADD B: Add the content of register B to the accumulator.
• SUB C: Subtract the content of register C from the
MVI A, 32H
accumulator. Operation: MVI A
Operand: Number 32H
2-Byte Instructions Binary Code:
0011 1110 3E
These instructions use two bytes. The first byte is the opcode, 1st byte
and the second byte specifies the operand, such as a register or 0011 0010 32
an immediate value. 2nd byte.
Examples: MVI A, 32H: Move the immediate value 32H into Instruction
register A. JMP 2085
Opcode: JMP
Operand: 2085
3-Byte Instructions Binary code:
These instructions use three bytes. The first byte is the opcode, 1100 0011 C3
and the next two bytes represent a 16-bit address or a register 1st byte.
1000 0101 85
pair. 2nd byte
Examples: 0010 0000 20
Data Transfer
Operations
• These instructions are used to transfer data between registers, memory, and I/O
ports.
MOV (Move): Transfers data from one register to another or between a register and
memory.
Example: MOV A, B (Move the content of register B to register)
• MVI (Move Immediate): Loads an immediate value into a register or memory location.
Example: MVI A, 32H (Load the value 32H into register)
• LXI (Load Register Pair Immediate): Loads a 16-bit immediate value into a register
pair.
Example: LXI H, 1234H (Load the value 1234H into register pair HL)
• STA (Store Accumulator): Stores the content of the accumulator into a specified
memory location.
Example: STA 3000H (Store the content of register A into memory location 3000H)
• LDA (Load Accumulator): Loads data from a specified memory location into the
accumulator.
Example: LDA 3000H (Load data from memory location 3000H into register A)
LXI instruction
8085 provides an instruction to place 16-bit data into the register pair in one step.
Instruction LXI Rp (Load eXtended Immediate)
Example: LXI B 4000H will place the 16-bit number 4000 into the register pair B, C.
upper two digits are placed in the 1st register of the pair and the lower two digits in
the 2nd
Memory “Register”
Most of the instructions of the 8085 can use a memory location in place of a register.
The memory location will become the “memory” register M.
Example: MOV M, B – copy the data from register B into a memory location.
Which memory location?
Memory location is identified by the contents of the HL register pair.
16-bit contents of the HL register pair are treated as a 16-bit address and used to identify
memory location.
There is also an instruction for moving data from memory to the accumulator without disturbing the contents of
the H and L register.
Instruction: LDAX Rp (LoaD Accumulator eXtended)
Copy the 8-bit contents of the memory location identified by the Rp register pair into Accumulator. This
instruction only uses the BC or DE pair. It does not accept the HL pair.
Arithmetic Instructions
Addition (ADD, ADI):
Any 8-bit number.
Can be added to the contents of the accumulator and the result is stored in the accumulator.
Subtraction (SUB, SUI):
Any 8-bit number.
Can be subtracted from the contents of the accumulator and the result is stored in the accumulator.
Arithmetic Operations related to Memory
ADD M : Add the contents of M to the Accumulator
SUB M : Sub the contents of M from the Accumulator
INR M / DCR M : Increment/decrement the contents of the memory location in place
All of these use the contents of the HL register pair to identify the memory location being used.
Manipulating Addresses
Now we have a 16-bit address in a register pair, how do we manipulate it?
It is possible to manipulate a 16-bit address stored in a register pair as one entity using some
special instructions. INX Rp (Increment the 16-bit number in the register pair)
DCX Rp (Decrement the 16-bit number in the register pair)
Logic Operations
These instructions perform logic operations on the contents of the accumulator.
ANA, ANI, ORA, ORI, XRA and XRI
Source: Accumulator and an 8-bit number
Destination: Accumulator
Instruction: ANA R/M (AND Accumulator With Reg/Mem)
Instruction: ANI # (AND Accumulator With an 8-bit number)
Instruction: ORA R/M (OR Accumulator With Reg/Mem)
Instruction: ORI # (OR Accumulator With an 8-bit number)
Instruction: XRA R/M (XOR Accumulator With Reg/Mem)
Instruction: XRI # (XOR Accumulator With an 8-bit number)
tack Instructions
hese instructions manage the stack memory.
USH: Pushes the content of a register pair onto the stack.
xample: PUSH B (Push the content of register pair BC onto the stack)
OP: Pops data from the stack into a register pair.
xample: POP D (Pop data from the stack into register pair DE)
Complement: • 1’s complement of the contents of the accumulator.
Instruction: CMA
Rotate – Rotate the contents of the accumulator one position to the left or right.
Instruction: RLC Rotate the accumulator left. Bit 7 goes to bit 0 AND the Carry flag.
Instruction: RAL Rotate the accumulator left through the carry. Bit 7 goes to the carry and carry
goes to bit 0.
Instruction: RRC Rotate the accumulator right. Bit 0 goes to bit 7 AND the Carry flag.
Instruction: RAR Rotate the accumulator right through the carry. Bit 0 goes to the carry and carry
goes to bit 7.
Compare
Compare contents of a register or memory location with the contents of the accumulator.
• Instruction: CMP R/M Compare the contents of the register or memory location to the
contents of the accumulator.
• CPI # Compare the 8-bit number to the contents of the accumulator.
• The compare instruction sets the flags (Z, CY, and S).
• The compare is done using an internal subtraction that does not change the contents of the
accumulator. A – (R / M / #)
Branch Operations
Two types:
• Unconditional branch. Go to a new location no matter
what.
• Conditional branch. Go to a new location if the condition is
true.
JMP Address : Jump to the address specified (Go to).
CALL Address Jump to the address specified but treat it as a
subroutine.
RET Return from a subroutine
The addresses supplied to all branch operations must
Conditional Branch
Go to new location if a specified condition is met.
JZ Address (Jump on Zero) – Go to address specified if the Zero flag is set.
JNZ Address (Jump on NOT Zero) –Go to address specified if the Zero flag is not set.
JC Address (Jump on Carry) – Go to the address specified if the Carry flag is set.
JNC Address (Jump on No Carry) – Go to the address specified if the Carry flag is not set.
JP Address (Jump on Plus) – Go to the address specified if the Sign flag is not set
JM Address (Jump on Minus) – Go to the address specified if the Sign flag is set
Machine Control
HLT - Stop executing the program.
NOP - No operation. Exactly as it says, do
nothing.
DI - Disables interrupts.
EI - Enables interrupts.