8085 Instruction Set Final Arti
8085 Instruction Set Final Arti
• It can be of 3 types
– Register to Register; eg. MOV A, C
• This instruction loads 16-bit data in the register pair (BC-B, DE-D, HL-H)
• HL pair is used as memory Pointer.
• Eg. LXI H, 2034 H
• The contents of a memory location, specified by a 16-bit address in the operand, are
copied to the accumulator.
• Example: LDA 2034H
• Practice: copy content of memory address 2060H to A without using any other reg.
Data Transfer Instructions-5, 6
• This instruction copies the contents of that memory location pointed by register pair
(BC or DE) into the accumulator.
• Example: LDAX B
• Note: HL pair is not used in this instruction.
• Practice: Copy 10H stored at memory location 3020H to accumulator using LDAX
instruction.
• This instruction copies the contents of memory location pointed out by 16-bit address
into register L. (( [16 bit address] → Reg. L)
• It copies contents of next memory location into reg. H. eg.[16 bit address +1] → Reg. H)
• Example: LHLD 2040 H
Data Transfer Instructions-7, 8
• The contents of accumulator are stored into the memory location specified by the
operand.
• Example: STA 2500 H
• Practice: copy content of A to memory address 2500H without using any other register.
• The contents of accumulator are stored/copied into the memory location specified by
the contents of the register pair.
• Example: STAX B
• Practice: copy 15H in A and store content of A to memory address 3100H using STAX.
Data Transfer Instructions-9, 10
• The contents of register L are stored into memory location specified by the 16-bit address.
( [16 bit address] ← Reg. L)
• The contents of register H are stored into the next memory location. [16 bit address +1] ←
Reg. H)
Subtraction:
Increment / Decrement
• The 8-bit contents of a register or a memory location can
be incremented or decremented by 1.
• Contents of register or memory and Carry Flag (CY) are added to the contents
of accumulator. The result is stored in accumulator.
[A] ← [A] + [r] + [CY].
• Note: This instruction is used only when some carry is generated from previous
addition.eg. It can be used to add two 16 bit data.
• Practice: Add 3465H and 2AB1H using ADC instruction. (HL ← DE+BC)
Arithmetic Instructions- Addition
• 8-bit data and the Carry Flag (CY) are added to contents of accumulator.
• The result is stored in accumulator. [A] ← [A] + data + [CY].
• All flags are modified to reflect the result of the addition.
• Example : ACI 45 H
Arithmetic Instructions- Addition
• Example : DAD B
Arithmetic Instructions- Subtraction
• The contents of the register or memory location and Borrow Flag (i.e.
CY)are subtracted from the contents of the accumulator.
• The result is stored in accumulator. [A] ← [A] – [r] – [CY]
• 8-bit data and the Borrow Flag (i.e. CY) is subtracted from contents of accumulator.
• The result is stored in accumulator. . [A] ← [A] – data – [CY]
• All flags are modified to reflect the result of subtraction.
• Example : SBI 45 H
Arithmetic Instructions- Increment
• Format- DAA
• In BCD addition:
Rotate
• Each bit in the accumulator can be shifted either left
or right to the next position.
Logical Instructions
Compare
• Any 8-bit data, or the contents of register, or memory
location can be compares for:
• Equality
• Greater Than
• Less Than
with the contents of accumulator.
Complement
• The contents of accumulator can be complemented.
• Each 0 is replaced by 1 and each 1 is replaced by 0.
Logical Instructions
i. ANA r. (AND register with accumulator)
ii. ANA M. (AND memory with accumulator).
iii. ANI data. (AND immediate data with accumulator)
iv. ORA r. (OR register with accumulator)
v. ORA M. (OR memory with accumulator)
vi. ORI data. (OR immediate data with accumulator)
vii. XRA r. (EXCLUSIVE – OR register with accumulator)
viii. XRA M. (EXCLUSIVE-OR memory with accumulator)
ix. XRI data. (EXCLUSIVE-OR immediate data with accumulator).
x. CMA. (Complement the accumulator)
x. CMC. (Complement the carry status)
xi. STC. (Set carry status)
xii. CMP r. (Compare register with accumulator)
xiii. CMP M. (Compare memory with accumulator
xiv. CPI data. (Compare immediate data with accumulator)
xv. RLC (Rotate accumulator left)
xvi. RRC. (Rotate accumulator right)
xvii. RAL. (Rotate accumulator left through carry)
xviii. RAR. (Rotate accumulator right through carry)
Logical Instructions : AND
• The contents of the accumulator are logically ANDed with the contents
of register or memory.
• The result is placed in the accumulator.
• If the operand is a memory location, its address is specified by the
contents of H-L pair.
• S, Z, P are modified to reflect the result of the operation.
• CY is reset and AC is set.
• Example: ANA B or ANA M.
• The contents of the accumulator are logically ANDed with 8-bit data.
• Example: ANI 86H.
Logical Instructions - OR
• The contents of the accumulator are logically Ored with the contents of the register or
memory.
• The result is placed in the accumulator.
• If the operand is a memory location, its address is specified by the contents of H-L pair.
• Example : ORA B or ORA M.
• The contents of the accumulator are logically ORedwith the 8-bit data.
• The result is placed in the accumulator.
• S, Z, P are modified to reflect the result.
• CY and AC are reset.
• Example : ORI 86H
Logical Instructions : OR
• The contents of the accumulator are XORed with the contents of the register or
memory.
• The result is placed in the accumulator.
• S, Z, P are modified to reflect the result of the operation. CY and AC are reset.
• If the operand is a memory location, its address is specified by H-L pair.
• Example : XRA B or XRA M.
• The contents of the accumulator are XORed with the 8-bit data.
• The result is placed in the accumulator.
• Example : XRI 86H.
Logical Instructions : Compare
• Each binary bit of the accumulator is rotated left by one position through the Carry flag.
• Bit D7 is placed in the Carry flag, and the Carry flag is placed in the least significant
position D0.
• CY is modified according to bit D7.
• S, Z, P, AC are not affected.
• Example : RAL.
• Each binary bit of A is rotated right by one position through the Carry flag.
• Bit D0 is placed in the Carry flag, and the Carry flag is placed in the MSB position D7.
• CY is modified according to bit D0.
• S, Z, P, AC are not affected.
• Example : RAR.
Logical Instructions - Complement
1. Carry Flag
2. Zero Flag
3. Sign Flag
4. Parity Flag
The program sequence is transferred to the memory location specified by the 16-bit
address given in the operand (subroutine address).
Before the transfer, the address of the next instruction after CALL (the contents of the
program counter) is pushed onto the stack.
• Example:CZ 2034 H.
Branching Instructions: Call Conditionally
Branching Instructions : Return
• The program sequence is transferred from the subroutine to the calling program.
• The two bytes from the top of the stack are copied into the program counter, and
program execution begins at the new address.
• Example:RET.
Branching Instructions : Return conditionally
Return
• The two bytes from the top of the stack are copied into the
program counter, and program execution begins at the new
address.
• Example:RZ.
Branching Instructions: Return conditionally
Branching Instructions: Restart
• Example: RST 3.
I/O, Control and Stack
Instructions
I/O Instructions
Opcode operand Description
IN 8 Bit Port address Copies data from I/O Port to
accumulator
• This instruction takes (copies/ reads) data from an input device and places the data byte
in the accumulator.
• [IN PORT] → A
• Example: IN 00H
• This instruction transfers (copies/ stores) the content of accumulator to the output device.
• A → [OUT PORT]
• Example: OUT 01H
• Address may range from 00H to FF H (Total 256 different output devices can be used)
Machine Control Instructions
• The machine control instructions control the operation of
microprocessor.
• No operation is performed.
• The instruction is fetched and decoded but no operation is executed.
• Example: NOP
• The CPU finishes executing the current instruction and halts any further
execution.
• An interrupt or reset is necessary to exit from the halt state.
• Example: HLT
Machine Control Instructions
• The interrupt enable flip-flop is reset and all the interrupts except the TRAP are
disabled.
• No flags are affected.
• Example: DI
• The interrupt enable flip-flop is set and all interrupts are enabled.
• No flags are affected.
• This instruction is necessary to re-enable the interrupts (except TRAP).
• Example: EI
Control Instructions
• This is a multipurpose
instruction used to read the
status of interrupts 7.5, 6.5,
5.5.
•
• Read serial data input bit.
• Example: RIM
Control Instructions
• This is a multipurpose
instruction and used to
implement the 8085
interrupts 7.5, 6.5, 5.5, and
serial data output.
• Example: SIM
Stack Instruction
• Stack is a reserved area of the memory where we
can store temporary information.
• Programmers use the stack to store data and the MP
use the stack to execute subroutines.
• First, the contents of the memory location indicated by the stack pointer
register are copied into the low-order register and then the stack pointer
register is incremented by 1.
• The contents of the next memory location are copied into the high-order
register and the stack pointer register is again incremented by 1.
Example:
LXI SP,2099H
LXI H, 42F2H
PUSH H
Delay Counter
POP H
After the execution of POP H instruction, the contents of the top of the stack location
shown by the stack pointer are copied in the L register and the stack pointer is increased by
one to 2098H
The contents of the top of the stack are copied in the H register and the stack pointer is
increased by one.
The contents of the memory locations 2097H and 2098H are not destroyed until some
other data bytes are stored in these locations