Documente Academic
Documente Profesional
Documente Cultură
Control
Memory of Microprocessor
• Inside (very small)
– The registers inside the microprocessor
• Outside
– Read Only Memory (ROM)
• used to store information that does not change
Input/Output/
Memory
Interrupts
Read
Write
Address Bus
(Unidirectional)
Similar function pins are
grouped in this figure- (called
functional pin diagram)
PIN FUNCTIONS
AD0-AD7: Lower order bidirectional multiplexed Address/Data lines.
A8-A15: Higher order unidirectional address lines, carries only address
ALE: A pulse output signal from this pin is used by microprocessor to
enable an 8-bit external latch to save the lower order address bits
S0,S1: These output status signals are used to indicate type of operation
RD: MP reads data from memory/IO device when this pin is active (low)
WR: MP writes data into memory/IO device when this pin is active (low)
READY: This pin is used by slow-responding peripheral devices to
indicate the µP whether they are READY to send/accept data to/from µP
TRAP: A highest priority , non mask able vectored interrupt. After TRAP,
restart occurs and execution starts from predefined vector address 0024H
RST5.5,6.5,7.5:These are maskable, vectored interrupts and have lower
priority than TRAP
INTR: INTR is a lowest priority non-vectored which can be used to
connect upto 8 peripheral devices by using an interrupt controller
INTA: An interrupt acknowledge signal pin for INTR, only
acknowledgment pin among all interrupts
PIN FUNCTIONS
HOLD & HLDA: When a peripheral device wants to gain control of system
buses (e.g. for a DMA operation), it sends request to µP via this input pin.
In response, µP activates HLDA (output) to acknowledge the request &
temporarily releases control over system buses.
IO/M: This output control pin is used to indicate whether the read/write
operation being performed by microprocessor is for memory (when low)
or for I/O device (when high)
RESET IN: This control input signal connected to external RESET button to
bring µP in initial standby mode. It restarts µp to memory location 0000H.
RESET OUT: When high, this indicates µP has been reset
SID & SOD: These pins are used for serial data communication by making
use of SIM & RIM instructions
X1X2 :These are clock input signals which are connected to external
oscillator of 6 MHz frequency which is divided by 2 internally in 8085 to
generate 3 MHz operating frequency .
CLK (out): Used to provide same 3MHz clock to the rest of the system
VCC, VSS & GND: Power supply pins VCC= +5V & VSS=GND=0V
INSTRUCTION FETCH & EXECUTION OPERATION IN 8085
Procedural steps of an example instruction (MOV C, A) (Hexcode: 4F) being fetched &
executed by microprocessor from memory location 2005:
Step 1: 8085 places 16-bits address (2005H) from program counter on address bus
Step 2: Control unit activates RD signal to enable memory chip (RAM)
Step 3: Instruction byte (4F) is placed by memory on data bus
Step 4: Instruction is decoded by Instruction decoder in binary form which directs timing
& control unit to generate appropriate control signals to carry out the task as specified by
the instruction
Multiplexing/Demultiplexing AD7-AD0
• AD7-AD0 lines serve dual purpose; they work in time-
shared mode: at one time they carry address & data
at other time, to save 8 extra pins on the chip
• For a read/write operation from memory, we must
provide complete 16-bit address for full duration (3
clock periods) of read/write cycle (until data is loaded
to/from memory.
• The 8 higher-order bits of the address remain on the
bus for full read/write cycle, but low-order bits
remain for only 1 clock period (to make data bus free
to carry data later). So we use an external 8-bit latch
(a chip) to save & hold lower-order address for the
remaining time (2 clock periods) or else it (lower
order address) would be lost.
• We use ALE control signal to activate (to save lower
order address) latch in the first clock period.
Multiplexing/Demultiplexing AD7-AD0
Activated in the
first clock cycle (T1)
to save lower order
address in latch Latch provides address to
Chip Selection
memory for remaining time A15-A10 Circuit
CS
A15-A8
ALE
8085 A9-A0 Memory
AD7-AD0 Latch Chip
A7- A 0
Activated for a
read (IN) Activated for a
operation write (OUT)
operation
The 8085 Instructions
CMP R: A-R, only flags changed as per result, then result discarded
CMP M: A-M, only flags changed as per result, then result discarded
CPI, data (8): A-data,only flags changed as per result, then result discarded
STC: Set (change to 1 if not already) the carry (CY) flag
CMC: Complement (0 to 1 or vice versa) the carry (CY) flag
IN port-addr (8): Copy 8-bit data available at 8-bit input port address to A
OUT port-addr (8): Copy contents of A to given 8-bit output port address
PUSH Rp: Store contents of given Rp in top two locations of stack
POP Rp: Load Rp with contents of top two locations from stack
PUSH PSW: Store 16-bit contents of PSW (contents of A & flag register) into
top two locations of stack
POP PSW: Load 16-bit contents of top two locations of stack into PSW (A &
flag register)
XTHL: Exchange contents of HL with top two locations of stack
SPHL: Copy contents of HL to stack pointer
EI/DI: Enables/Disables all maskable interrupts
SIM/RIM: Explained earlier
NOP: No operation performed, used to provide delay in some programs
HLT: Halts the program
INSTRUCTION WORD SIZE IN 8085
• One-Byte Instructions: Occupies 1 byte in the
memory, no 8/16 bits data is included in the instructions
Examples: MOV A, B ADD B RAL MOV C, M
CMC STC CMP M ANA B INR C
• Two-Bytes Instructions: Occupies total 2 bytes in the
memory, 8-bits data is included in the instructions
Examples: MVI A, 05 IN 02 CPI 03
• Three-Bytes Instructions: Occupies total 3 bytes in
the memory, 16-bits data is included in the instructions
Examples: LXI H, 2500 LDA 3050 LHLD 2600
8085 ADDRESSING MODES
Addressing Mode: An addressing mode indicates the location
of operand in an instruction
Instruction cycle
Opcode
Execution Cycle
Fetch Cycle
(MR/MW/IOR/IOW)
4 T-states
T – State 1
T – State 2
T – State 3
T – State 6
No. of m/c
cycles reqd. Example Instructions
78H
WR
Note: A fetch cycle always
requires 4 T-states
IO/M
S0 & S1 control signals may also be shown in the above & all other timing diagrams. They
may be shown separately or combined with IO/M
Example Timing Diagram of an instruction requiring 2 machine cycles
CLK
Instruction:
T1 T2 T3 T4 T5 T6 T7
ALE
Hex Codes:
3E, 45H RD
WR
T1 T2 T3 T4 T5 T6 T7 T8 T9 T10
A8- A15
30H 30H 30H
AD0 -AD7
10H 21H 11H 35H 12H 20H
OUT IN OUT IN OUT IN
ALE
RD
WR
IO/M
Another example of an instruction requiring 2 machine cycles
T1 T2 T3 T4 T5 T6 T7
A8- A15 26H Content Of Reg H
RD
Hex Code: 7E
WR
IO/M
T1 T2 T3 T4 T5 T6 T7
RD
Hex Code: 77H
WR
IO/M
2000 LXI SP, 2099H Load SP with an arbitrary address, say 2099, to initialize stack
2003 LXI H, 42F2H Load any 16 bit value in the HL register pair, say 42F2
2006 PUSH H The content of the HL register pair are pushed (written) into stack.
… Contents of H (42H) are stored first in the location addressed by SP-
… 1* i.e. 2098 (higher location for higher register) & contents of L
… (F2H) are stored then in SP-2 i.e. 2097 (lower location for lower
register). New address in SP after the PUSH operation is 2097.
2010 POP D Contents of two locations from stack are loaded into DE pair. The
… 1st location is addressed by SP** (now containing 2097) & the 2nd
… location is addressed by SP+1 (2098). So, E is loaded first with F2H
& then D is loaded with 42H. New address in SP after this POP
operation is 2098.
Note: *As mentioned earlier, the first available location for storage in the stack is always SP-
1 (2098 in the above example). Also, because a PUSH instruction copies contents of a
register pair (HL, BC or DE), it requires two (consecutive) memory locations in the stack.
** As mentioned earlier, the first memory location that is readable from stack is SP (=2097
here, after execution of PUSH instruction). Also, because a POP instruction loads a register
pair, it reads two locations (bytes) from the stack
Execution of PUSH H
Execution of PUSH H instruction, as explained in the previous
example, is illustrated here:
Level
INTR Lowest Yes DI / EI No
Sensitive
DI / EI Edge
RST 7.5 Yes Yes
SIM Sensitive
Level &
TRAP Highest No None Yes Edge
Sensitive
SIM Instruction
SIM instruction can be used to perform two different tasks: 1. For masking of 3
interrupts 2. For serial data transmission (Each time a SIM instruction is executed, 7th bit
of Accumulator is automatically copied to SOD pin of 8085)
M5.5
M7.5
M6.5
MSE
SDO
R7.5
SDE
XXX
RST5.5 Mask
Serial Data Output RST6.5 Mask
RST7.5 Mask
} 0 –Available
(not masked)
1 - Masked
M5.5
M7.5
M6.5
SDO
MSE
R7.5
SDE
XXX
- Disable 6.5 bit 1 = 1
- Enable 7.5 bit 2 = 0
0 0 0 0 1 0 1 0
- Allow setting the masks bit 3 = 1
- Don’t reset the flip flop bit 4 = 0
- Bit 5 is not used bit 5 = 0 Contents of accumulator are: 0AH
- Don’t use serial data bit 6 = 0
- Serial data is ignored bit 7 = 0
• Now use following set of instructions to implement required masks using SIM
EI
MVI A, 0A
SIM
First of all enable all interrupts using EI instruction without using which SIM wouldn't be
effective
Move the prepared bit pattern (0AH here) to Accumulator
SIM instruction interprets contents of Accumulator same as per the above format &
performs the desired operation of masking the respective interrupts
RIM instruction
Like SIM instruction, RIM can be used to perform two different tasks: 1. To read current
status of 3 maskable interrupts 2. For serial data reception (Each time a SIM instruction
is executed, the bit present on SID pin of 8085 is automatically moved to 7th bit of the
Accumulator)
7 6 5 4 3 2 1 0
M5.5
M7.5
M6.5
P6.5
P7.5
P5.5
SDI
IE
Indicate current
RST5.5 Mask masking status of
Serial Data In RST6.5 Mask
RST7.5 Mask
} interrupts set by user
(using SIM)
0 -Available
RST5.5 Interrupt Pending 1 - Masked
RST6.5 Interrupt Pending
RST7.5 Interrupt Pending Status of Interrupt Enable Flip Flop: 1
Set 0 Reset
Pending Interrupts: Since the 8085 has 5 interrupt lines, another interrupts may
occur while an interrupt is being attended and thus remain pending. Such
interrupts are called pending interrupts & would be attended as soon as ISR of
current interrupt is executed. A programmer may know the status (current value of
high/low on the respective interrupt pin) of such interrupts anytime by using RIM
instruction.
An example of Memory Mapping & Address allocations in 8085
The memory map is a pictorial representation of the
memory address ranges of different memory chips (for
example 5 no. of chips here) of different sizes and shows
where they are located within the full address range
available.
0000 0000
EPROM Address Range of EPROM Chip
3FFF
4400
RAM 1 Address Range of 1st RAM Chip
5FFF
Address Range
6000
F7FF
FFFF