Unit I PDF
Unit I PDF
8085 ARCHITECTURE
Introduction-8085 Architecture-Block Diagram, Flag Register, Pin
Diagram, Timing and Control Signals, System Timing Diagram,
Instruction Set of 8085- Instruction & Data Formats- Addressing
Modes-Instructions.
Introduction:
The features of INTEL 8085 are:
It is an 8 bit processor.
It is a single chip N-MOS device with 40 pins.
It has multiplexed address and data bus. (AD0-AD7).
It works on 5 Volt dc power supply.
The maximum clock frequency is 3 MHz while minimum frequency is 500 kHz.
It provides 16 address lines so it can access 2^16 =64 Kbytes of memory.
It generates 8 bit I/O address so it can access 2^8=256 input ports.
8085 Architecture:
The internal architecture of 8085 includes the ALU, timing and control unit, instruction register
and decoder, register array, interrupt control and serial I/O control. The ALU performs the arithmetic
and logical operations. The operations performed by ALU of 8085 are addition, subtraction, increment,
decrement, logical AND, OR, EXCL U8IVE -OR, compare, complement and left / right shift.
The accumulator and temporary register are used to hold the data during an arithmetic / logical
operation. After an operation the result is stored in the accumulator and the flags are set or reset
according to the result of the operation.
Registers:
The 8085includes six registers, one accumulator, and one flag register, as shown in Figure. In
addition, it has two 16-bit registers: the stack pointer and the program counter. The 8085 has six
general-purpose registers to store 8-bit data; these are identified as B, C, D, E, H, and L as shown in the
figure.
They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit operations.
The programmer can use these registers to store or copy data into the registers by using data copy
instructions.
Accumulator
The 8085 microprocessor is an accumulator (A) based microprocessor, Accumulator register must
be the one of the operand in Arithmetic and logical operations. The accumulator is an 8-bit register that
is a part of arithmetic/logic unit (ALU). This register is used to store 8-bit data and to perform arithmetic
and logical operations. The result of an operation is stored in the accumulator. The accumulator is also
identified as register A.
Flag Register
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
The 8085 microprocessor is available on a 40-pin Dual-in-Line package (DIP). The following
describes the function of each pin:
READY (Input):
If Ready is high during a read or write cycle, it indicates that the memory or peripheral is ready
to send or receive data. If Ready is low, the CPU will wait for Ready to go high before completing the
read or write cycle.
HOLD (Input):
Indicates that another Master is requesting the use of the Address and Data Buses. The CPU,
upon receiving the Hold request. will relinquish the use of buses as soon as the completion of the current
machine cycle. Internal processing can continue. The processor can regain the buses only after the Hold
is removed. When the Hold is acknowledged, the Address, Data, RD, WR, and IO/M lines are 3stated.
HLDA (Output): HOLD ACKNOWLEDGE
Indicates that the CPU has received the Hold request and that it will relinquish the buses in the
next clock cycle. HLDA goes low after the Hold request is removed. The CPU takes the buses one half
clock cycle after HLDA goes low.
TRAP (Input):
Trap interrupt is a non-maskable restart interrupt. It is recognized at the same time as INTR. It is
unaffected by any mask or Interrupt Enable. It has the highest priority of any interrupt.
RESET IN (Input):
Reset sets the Program Counter to zero and resets the Interrupt Enable and HLDA flip-flops.
None of the other flags or registers (except the instruction register) are affected The CPU is held in the
reset condition as long as Reset is applied.
CLK (Output):
Clock Output for use as a system clock when a crystal or R/ C network is used as an input to the
CPU. The period of CLK is twice the X1, X2 input period.
IO/M (Output):
IO/M indicates whether the Read/Write is to memory or l/O Tristated during Hold
and Halt modes.
Vcc:
+5 volts supply.
Vss:
Ground Reference.
To perform any operation, we have to give the corresponding instructions to the microprocessor.
In each instruction, programmer has to specify 3 things:
Operation to be performed.
Address of source of data.
Address of destination of result.
The method by which the address of source of data or the address of destination of result is given
in the instruction is called Addressing Modes. The term addressing mode refers to the way in which the
operand of the instruction is specified. Intel 8085 uses the following addressing modes:
1. Direct Addressing Mode
2. Register Addressing Mode
3. Register Indirect Addressing Mode
4. Immediate Addressing Mode
5. Implicit Addressing Mode
Ex: - LDA 2500H Load the contents of memory location 2500H in Accumulator.
LDA is the operation.
2500 H is the address of source.
Accumulator is the destination.
MOV Rd, Rs
M, Rs
Rd, M
Example: MOV B, C
This instruction copies the contents of the source register into the destination register; the contents of the
source register are not altered. If one of the operands is a memory location, its location is specified by the
contents of the HL registers.
The 8-bit data is stored in the destination register or memory. If the operand is a memory location, its
location is specified by the contents of the HL registers.
Load accumulator
The contents of the designated register pair point to a memory location. This instruction copies the
contents of that memory location into the accumulator. The contents of either the register pair or the memory
location are not altered.
The instruction copies the contents of the memory location pointed out by the 16-bit address into
register L and copies the contents of the next memory location into register H. The contents of source memory
locations are not altered.
The contents of register L are stored into the memory location specified by the 16-bit address in the
operand and the contents of H register are stored into the next memory location by incrementing the
operand. The contents of registers HL are not altered. This is a 3-byte instruction, the second byte specifies
the low-order address and the third byte specifies the high-order address.
SPHL none
Example: SPHL
The instruction loads the contents of the H and L registers into the stack pointer register, the
contents of the H register provide the high-order address and the contents of the L register provide the
low-order address. The contents of the H and L registers are not altered.
XTHL none
Example: XTHL
The contents of the L register are exchanged with the stack location pointed out by the contents of
the stack pointer register. The contents of the H register are exchanged with the next stack location (SP+1);
however, the contents of the stack pointer register are not altered.
The contents of the register pair designated in the operand are copied onto the stack in the following
sequence. The stack pointer register is decremented and the contents of the high- order register (B, D, H, A)
are copied into that location. The stack pointer register is decremented again and the contents of the low-order
register (C, E, L, flags) are copied to that location.
Pop off stack to register pair
The contents of the memory location pointed out by the stack pointer register are copied to the low-order
register (C, E, L, status flags) of the operand. The stack pointer is incremented by 1 and the contents of that
memory location are copied to the high-order register (B, D, H, A) of the operand. The stack pointer register is
again incremented by 1.
The contents of the accumulator are copied into the I/O port specified by the operand.
Example: IN 82H
The contents of the input port designated in the operand are read and loaded into the accumulator.
ARITHMETIC INSTRUCTIONS
ADD R
M
Example: ADD B or ADD M
The contents of the operand (register or memory) are added to the contents of the accumulator and the
result is stored in the accumulator. If the operand is a memory location, its location is specified by the
contents of the HL registers. All flags are modified to reflect the result of the addition.
Add register to accumulator with carry
ADC R
M
Example: ADC B or ADC M
The contents of the operand (register or memory) and the Carry flag are added to the contents of the
accumulator and the result is stored in the accumulator. If the operand is a memory location, its location is
specified by the contents of the HL registers. All flags are modified to reflect the result of the addition.
Add immediate to accumulator
The 8-bit data (operand) is added to the contents of the accumulator and the result is stored in the
accumulator. All flags are modified to reflect the result of the addition.
The 8-bit data (operand) and the Carry flag are added to the contents of the accumulator and the
result is stored in the accumulator. All flags are modified to reflect the result of the addition.
Example: DAD H
The 16-bit contents of the specified register pair are added to the contents of the HL register and the
sum is stored in the HL register. The contents of the source register pair are not altered. If the result is
larger than 16 bits, the CY flag is set. No other flags are affected.
SUB R
M
Example: SUB B or SUB M
The contents of the operand (register or memory ) are subtracted from the contents of the accumulator,
and the result is stored in the accumulator. If the operand is a memory location, its location is specified by
the contents of the HL registers. All flags are modified to reflect the result of the subtraction.
Subtract source and borrow from accumulator
SBB R
M
Example: SBB B or SBB M
The contents of the operand (register or memory ) and the Borrow flag are subtracted from the
contents of the accumulator and the result is placed in the accumulator. If the operand is a memory location,
its location is specified by the contents of the HL registers. All flags are modified to reflect the result of the
subtraction.
Subtract immediate from accumulator
SUI 8-bit data
Example: SUI 45H
The 8-bit data (operand) is subtracted from the contents of the accumulator and the result is stored in the
accumulator. All flags are modified to reflect the result of the subtraction.
Subtract immediate from accumulator with borrow
The contents of the designated register or memory) are incremented by 1 and the result is stored in the
same place. If the operand is a memory location, its location is specified by the contents of the HL registers.
Increment register pair by 1
INX R
Example: INX H
The contents of the designated register pair are incremented by 1 and the result is stored in the same
place.
Decrement register or memory by 1
DCR R
M
Example: DCR B or DCR M
The contents of the designated register or memory are decremented by 1 and the result is stored in the same
place. If the operand is a memory location, its location is specified by the contents of the HL registers.
Decrement register pair by 1
DCX R
Example: DCX H
The contents of the designated register pair are decremented by 1 and the result is stored in the same
place.
Decimal adjust accumulator
DAA none
Example: DAA
The contents of the accumulator are changed from a binary value to two 4-bit binary coded decimal
(BCD) digits. This is the only instruction that uses the auxiliary flag to perform the binary to BCD conversion,
and the conversion procedure is described below. S, Z, AC, P, CY flags are altered to reflect the results of the
operation. If the value of the low-order 4-bits in the accumulator is greater than 9 or if AC flag is set, the
instruction adds 6 to the low-order four bits. If the value of the high-order 4-bits in the accumulator is
greater than 9 or if the Carry flag is set, the instruction adds 6 to the high-order four bits.
BRANCHING INSTRUCTIONS
Jump unconditionally
The program sequence is transferred to the memory location specified by the 16-bit address given in the
operand.
Jump conditionally
Example: JZ 2034H
JC Jump on Carry CY = 1
The program sequence is transferred to the memory location specified by the 16-bit address given
in the operand. Before the transfer, the address of the next instruction after CALL (the contents of the
program counter) is pushed onto the stack.
Call conditionally
Example: CZ 2034H
The program sequence is transferred to the memory location specified by the 16-bit address given in
the operand based on the specified flag of the PSW as described below. Before the transfer, the address of
the next instruction after the call (the contents of the program counter) is pushed onto the stack.
CC Call on Carry CY = 1
RET none
Example: RET
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.
Return from subroutine conditionally
Operand: none
Example: RZ
The program sequence is transferred from the subroutine to the calling program based on the specified
flag of the PSW as described below. The two bytes from the top of the stack are copied into the program
counter, and program execution begins at the new address.
RC Return on Carry CY = 1
RM Return on minus S = 1
RZ Return on zero Z=1
PCHL none
Example: PCHL
The contents of registers H and L are copied into the program counter. The contents of H are placed as the
high-order byte and the contents of L as the low-order byte.
Restart
RST 0-7
The RST instruction is equivalent to a 1-byte call instruction to one of eight memory locations depending
upon the number. The instructions are generally used in conjunction with interrupts and inserted using external
hardware. However these can be used as software instructions in a program to transfer program execution to
one of the eight locations.
The addresses are:
Instruction Restart Address
RST 0 0000H
RST 1 0008H
RST 2 0010H
RST 3 0018H
RST 4 0020H
RST 5 0028H
RST 6 0030H
RST 7 0038H
The 8085 has four additional interrupts and these interrupts generate RST instructions internally and
thus do not require any external hardware. These instructions and their Restart addresses are:
TRAP 0024H
CMP R
M
Example: CMP B or CMP M
The contents of the operand (register or memory) are compared with the contents of the accumulator. Both
contents are preserved. The result of the comparison is shown by setting the flags of the PSW as follows:
if (A) < (reg/mem): carry flag is set (CY=1)
if (A) = (reg/mem): zero flag is set (ZF=1)
if (A) > (reg/mem): carry and zero flags are reset (CY=0)
Compare immediate with accumulator
ANA R
M
Example: ANA B or ANA M
The contents of the accumulator are logically ANDed with the contents of the operand (register or
memory), and the result is placed in the accumulator. If the operand is a memory location, its address is
specified by the contents of HL registers. S, Z, P are modified to reflect the result of the operation. CY is
reset. AC is set.
Logical AND immediate with accumulator
ANI 8-bit data
Example: ANI 86H
The contents of the accumulator are logically ANDed with the 8-bit data (operand) and the result is
placed in the accumulator. S, Z, P are modified to reflect the result of the operation. CY is reset. AC is set.
Exclusive OR register or memory with accumulator
XRA R
M
Example: XRA B or XRA M
The contents of the accumulator are Exclusive ORed with the contents of the operand (register or
memory), and the result is placed in the accumulator. If the operand is a memory location, its address is
specified by the contents of HL registers. S, Z, P are modified to reflect the result of the operation. CY and
AC are reset.
Exclusive OR immediate with accumulator
ORA R
M
Example: ORA B or ORA M
The contents of the accumulator are logically ORed with the contents of the operand (register or
memory), and the result is placed in the accumulator.
If the operand is a memory location, its address is specified by the contents of HL registers. S, Z, P are
modified to reflect the result of the operation. CY and AC are reset.
Logical OR immediate with accumulator
The contents of the accumulator are logically ORed with the 8-bit data (operand) and the result is
placed in the accumulator. S, Z, P are modified to reflect the result of the operation. CY and AC are reset.
Rotate accumulator left
RLC none
Example: RLC
Each binary bit of the accumulator is rotated left by one position. Bit D7 is placed in the position of
D0 as well as in the Carry flag. CY is modified according to bit D7. S, Z, P, AC are not affected.
Rotate accumulator right
RRC none
Example: RRC
Each binary bit of the accumulator is rotated right by one position. Bit D0 is placed in the position of
D7 as well as in the Carry flag. CY is modified according to bit D0. S, Z, P, AC are not affected.
Rotate accumulator left through carry
RAL none
Example: RAL
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.
Rotate accumulator right through carry
RAR none
Example: RAR
Each binary bit of the accumulator 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 most significant position D7. CY is modified
according to bit D0. S, Z, P, AC are not affected.
Complement accumulator
CMA none
Example: CMA
The contents of the accumulator are complemented. No flags are affected.
Complement carry
CMC none
Example: CMC
The Carry flag is complemented. No other flags are affected.
Set Carry
STC none
Example: STC
The Carry flag is set to 1. No other flags are affected.
CONTROL INSTRUCTIONS
No operation
NOP none
Example: NOP
No operation is performed. The instruction is fetched and decoded. However no operation is executed.
Halt and enter wait state
HLT none
Example: HLT
The CPU finishes executing the current instruction and halts any further execution. An interrupt or
reset is necessary to exit from the halt state.
Disable interrupts
DI none
Example: DI
The interrupt enable flip-flop is reset and all the interrupts except the TRAP are disabled. No flags are
affected.
Enable interrupts
EI none
Example: EI
The interrupt enable flip-flop is set and all interrupts are enabled. No flags are affected. After a system
reset or the acknowledgement of an interrupt, the interrupt enable flip- flop is reset, thus disabling the
interrupts. This instruction is necessary to re-enable the interrupts (except TRAP).
Read interrupt mask
RIM none
Example: RIM
This is a multipurpose instruction used to read the status of interrupts 7.5, 6.5, 5.5 and read serial data input
bit. The instruction loads eight bits in the accumulator with the following interpretations.
SIM none
Example: SIM
This is a multipurpose instruction and used to implement the 8085 interrupts 7.5, 6.5, 5.5, and serial data
output. The instruction interprets the accumulator contents as follows.
TIMING DIAGRAM:
Timing Diagram is a graphical representation. It represents the execution time taken by each instruction in a
graphical format. The execution time is represented in T-states.
Instruction Cycle
The time required to execute an instruction is called instruction cycle.
Machine Cycle
The time required to access the memory or input/output devices is called machine cycle.
T-State
The machine cycle and instruction cycle takes multiple clock periods.
A portion of an operation carried out in one system clock period is called as T-state.
Machine cycles of 8085
The 8085 microprocessor has 5 basic machine cycles. They are
1. Opcode fetch cycle (4T)
2. Memory read cycle (3 T)
3. Memory write cycle (3 T)
4. I/O read cycle (3 T)
5. I/O write cycle (3 T)
Fig: Clock signal
Opcode fetch machine cycle of 8085 :
Each instruction of the processor has one byte opcode.
The opcodes are stored in memory. So, the processor executes the opcode fetch machine cycle to fetch
the opcode from memory.
Hence, every instruction starts with opcode fetch machine cycle.
The time taken by the processor to execute the opcode fetch cycle is 4T.
In this time, the first, 3 T-states are used for fetching the opcode from memory and the remaining T-
states are used for internal operations by the processor.
The I/O Read cycle is executed by the processor to read a data byte from I/O port or from the
peripheral, which is I/O, mapped in the system.
The processor takes 3T states to execute this machine cycle.
The IN instruction uses this machine cycle during the execution.