EET 303 M1 Ktunotes - in
EET 303 M1 Ktunotes - in
EET 303 M1 Ktunotes - in
MODULE-1
Syllabus
Internal architecture of 8085 microprocessor–Functional block diagram
Machine cycles and T states – Fetch and execute cycles- Timing diagram for instruction and data
flow.
Architecture of 8085
The architecture of 8085 is shown in figure 1.2. The internal architecture of 8085 includes the ALU,
register array, timing and control unit, instruction register and decoder, interrupt control and serial
I/O control.
ALU:
Functions of ALU:
➢ It performs arithmetic operations like ; addition, subtraction, increment, etc.
➢ It performs logical operations like ; AND ing, OR ing, X-OR ing, NOT etc.
➢ It accepts operands from accumulator and temporary register.
Register Array:
➢ The 8085/8080A has six general-purpose registers to store 8-bit data; these are identified as
B,C,D,E,H, and L.
➢ They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit operations.
➢ The temporary registers W and Z are intended for internal use of the processor and it cannot
be used by the programmer.
2. Accumulator:
➢ 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 is a flip-flop which changes its status according to the result stored in the
accumulator.
➢ Flag register is also known as status register.
➢ 8085 has an 8-bit Flag register with 5 active flags. They are called Zero (Z), Carry (CY),
Sign (S), Parity (P), and Auxiliary Carry (AC) flags.
➢ The bit position of the flip flop in flag register is:
Sign Flag- If D7 of the result is 1 then sign flag is set otherwise reset. As we know that a
number on the D7 always decides the sign of the number.
Zero Flag (Z)-If the result stored in an accumulator is zero then this flag is set otherwise it is
reset.
Auxiliary carry Flag (AC)-If any carry goes from D3 to D4 in the result, then it is set otherwise
it is reset.
Parity Flag (P)-If the no of 1's in the result stored in the accumulator is even, then it is set
otherwise it is reset for the odd.
Carry Flag (C)-If the result stored in an accumulator generates a carry in its final output then
it is set otherwise it is reset.
➢ When a byte (machine code) is being fetched, the program counter is incremented by
one to point to the next memory location.
Instruction Decoder:
➢ Instruction decoder takes bits stored in the instruction register and decodes it and tells to
CPU what it need to do for it and enable the components for the operation.
➢ Simply, instruction decoder is like a dictionary. It tells the meaning of the instruction.
➢ It provides timing and control signal to the microprocessor to perform the various
operations.
➢ It has three control signals. It controls all external and internal circuits.
➢ It operates with reference to clock signal.
➢ It synchronizes all the data transfers.
➢ There are two pins in this unit. This unit is used for serial data communication.
Interrupt Unit:
1.2 Instructions
➢ An instruction is a command to the microprocessor to perform a given task on a specified data.
Each instruction has two parts: one is task to be performed, called the operation code (op-
code), and the second is the data to be operated on, called the operand.
2. Arithmetic Instructions
These instructions perform arithmetic operations such as addition, subtraction,
increment, and decrement.
Addition:-
➢ Any 8-bit number, or the contents of a register or the contents of a memory location can be
added to the contents of the accumulator and the sum is stored in the accumulator.
➢ No two other 8-bit registers can be added directly (e.g., the contents of register B cannot be
added directly to the contents of the register C).
➢ Eg:- ADD B,ADI 09
Subtraction:-
➢ Any 8-bit number, or the contents of a register, or the contents of a memory location can be
subtracted from the contents of the accumulator and the results stored in the
accumulator.
➢ The subtraction is performed in 2's compliment, and the results if negative, are expressed in
2's complement. No two other registers can be subtracted directly.
➢ Eg:- SUB C, SBI 08
Increment/Decrement:-
➢ The 8-bit contents of a register or a memory location can be incremented or decrement by 1.
Similarly, the 16-bit contents of a register pair (such as BC) can be incremented or decrement
by 1.
➢ Eg:- INR D, DCR D
3. Logical Instructions
These instructions perform various logical operations with the contents of the accumulator.
AND, OR Exclusive-OR: -
➢ Any 8-bit number, or the contents of a register, or of a memory location can be logically ANDed,
ORed, or Exclusive-ORed with the contents of the accumulator.
➢ The results are stored in the accumulator.
➢ Eg:- ANA D, ORA C
Rotate:-
➢ Each bit in the accumulator can be shifted either left or right to the next position.
➢ Eg:- RLC,RAL,RRC,RAR
Compare:-
Downloaded from Ktunotes.in
➢ Any 8-bit number or the contents of a register, or a memory location can be compared for
equality, greater than, or less than, with the contents of the accumulator.
Eg:- CMP B, CPI 08
Complement:-
➢ The contents of the accumulator can be complemented. All 0s are replaced by 1s and all 1s are
replaced by 0s.
Eg:- CMA
4. Branching Instructions
This group of instructions alters the sequence of program execution either conditionally or
unconditionally.
Jump:-
➢ Conditional jumps are an important aspect of the decision-making process in the
programming.
➢ These instructions test for a certain conditions (e.g., Zero or Carry flag) and alter the program
sequence when the condition is met.
Eg:- JC address ,JNC address, JZ address
➢ In addition, the instruction set includes an instruction called unconditional jump.
Eg:- JMP address
Call, Return, and Restart:-
➢ These instructions change the sequence of a program either by calling a subroutine or
returning from a subroutine.
➢ The conditional Call and Return instructions also can test condition flags.
Eg:- CALL address, RET
Immediate Addressing
Eg. MVI B, 3EH - Move the data 3EH given in the instruction to B register.
Direct Addressing
Eg. LDA 1050H - Load the data available in memory location 1050H in accumulator.
Register Addressing
➢ In register addressing mode, the instruction specifies the name of the register in which the data is
available.
➢ This type of addressing can be identified by register names (such as ‘A’, ‘B’, … ) in the instruction.
Eg. MOV A, B -Move the content of B register to A register.
➢ In register indirect addressing mode, the instruction specifies the name of the register in which
the address of the data is available.
➢ Here the data will be in memory and the address will be in the register pair.
➢ This type of addressing can be identified by letter ‘M’ present in the instruction.
Implied Addressing
➢ In implied addressing mode, the instruction itself specifies the type of operation and location
of data to be operated.
➢ This type of instruction does not have any address, register name, immediate data specified
along with it.
Eg. CMA - Complement the content of accumulator.
T-state:
➢ T-state is the time corresponding to one clock period. It is a basic unit used to calculate
the time taken for execution of instructions and programs in a processor.
Machine Cycle:
➢ A machine cycle is the time required to complete one operation of accessing the
memory, I/O or acknowledge an external signal or request.
➢ Usually machine cycle consists of 3 to 6 T-states.
➢ The different types of machine cycle available in 8085 microprocessor are:
o Opcode Fetch
o Memory Read
o Memory write
Downloaded from Ktunotes.in
o I/O Read
o I/O Write
o INTR Acknowledge
o Bus Idle
Instruction Cycle:
The memory read machine cycle is executed by the processor to read a data byte from memory. The
processor takes 3 T-states to execute this cycle. The timings of various signals during memory read
cycle are shown below.
➢ The microprocessor outputs the low byte address on AD0 – AD7 lines and high byte address
on A8 to A15 lines.
➢ ALE is asserted high to enable the address latch.
➢ The other control signals are as follows
IO/M =0, S0=0, S1=1.
➢ Data from data bus are placed into the specified register (A,B, C, etc.) and raises RD so that
memory is disabled.
➢ The microprocessor outputs the low byte address on AD0 – AD7 lines and high byte address
on A8 to A15 lines.
➢ ALE is asserted high to enable the address latch.
➢ The other control signals are as follows
IO/M =0, S0=1, S1=0.
➢ During this state the data to be written is placed on the Data bus.
➢ The write control signal WR goes low.
➢ The data which was placed on the data bus is now transferred to the specific memory
location.
➢ In the middle of this state the WR goes high and disables the memory.
The I/O Read cycle is executed by the processor to read a data byte from I/O port. The processor
takes 3 T-states to execute this machine cycle. The timings of various signals during this machine
cycle are shown in figure below.
➢ The microprocessor outputs the 8 bit port address on both the low order address lines
(AD0-AD7) and high order address lines (A8 to A15).
➢ ALE is asserted high to enable the address latch. The other control signals are asserted as
follows.
IO/M =1, S0=0 and S1=1. (IO/M is asserted high to indicate I/O read operation).
➢ The I/O device is requested for read by asserting read line RD low.
➢ When RD is asserted low, the I/O port is enabled for placing the data on the data bus.
➢ The data is transferred into microprocessor. The read signal is asserted high. Other control
signals remains in the same state until the next machine cycle.
➢ The microprocessor outputs the 8 bit port address on both the low order address lines
(AD0-AD7) and the high order address lines.
➢ ALE is asserted high to enable the address latch. The other control signals are asserted as
follows.
IO/M =1, S0=1 and S1=0. (IO/M is asserted high to indicate I/O read operation).
➢ The data which was placed on the data bus in the previous state is now transferred to the
I/O device.
➢ In the middle of this state the WR goes high and disables the I/O device.
The time taken by the processor to execute the opcode fetch cycle is either 4T or 6T. In this time,
the first 3T-states are used for fetching the opcode from memory and the remaining T-states are
used for internal operations by the processor. The timings of various signals during opcode fetch
cycle is shown as:
➢ The microprocessor outputs the low byte address on AD0 – AD7 lines and high byte address
on A8 to A15 lines.
➢ ALE is asserted high to enable the address latch.
➢ The other control signals are as follows
IO/M =0, S0=1, S1=1.
➢ Data from data bus are placed into the Instruction Register and raises RD so that memory is
disabled.
➢ This t-state is used for internal operations by the processor like decoding.
---------------------------------------------------------Exercise--------------------------------------------------------------
The instruction MOV A,B is a 1-byte instruction. Microprocessor takes only one machine cycle (op-code
fetch) to complete instruction. Hence, hex code for MOV A,B is passed to the microprocessor.
Ans.
• Arithmetic Instructions
• Logic Instructions
• Branch Instructions
Sl No Types Examples
Between memory
3 Copy from location 2000H to register B
location and a register
1. 1-byte instructions
2. 2-byte instructions
3. 3-byte instructions
• Example
Hex
Task Opcode Operand Binary Code
Code
Copy contents of Accumulator to
MOV C,A 0100 1111 4FH
register C
Add contents of register B to contents
ADD B 1000 0000 80H
of accumulator
Complement each bit in accumulator CMA 0010 1111 2FH
• Example
Hex
Task Opcode Operand Binary Code
Code
• Example
Hex
Task Opcode Operand Binary Code
Code
0011 1010 3AH
Load contents of Memory location
LDA 2050H 0101 0000 50H
2050H into accumulator
0010 0000 20H
• Example,
– MVI B, 45
– LXI H, 3050
– JMP 8004
• Example,
– LDA 2050 – load contents of memory location 2050 to Accumulator
– LHLD 9500 – load contents of 16-bit memory into HL pair
• Example,
– MOV A, B
– ADD B
– INR A
• Example
– MOV A,M – Move contents of the memory location pointed by HL pair
registers
– LDAX B – Move contents of B-C register pair to Accumulator
• Example,
– CMA – Complement contents of Accumulator
– RRC – Rotate Accumulator content right by 1bit
– RLC – Rotate Accumulator content left by 1 bit
1.3 LXI Rp, 16-bit LXI B, 2050 Load 16-bit number to a register pair
2.2 ADD 8-bit ADI 37 Add the data to the contents of A register
3.2 ANI 8-Bit ANI 2F Logical AND 8-bit data with contents of A register
3.5 ORI 8-bit ORI 3F Logical OR 8-bit data with contents of A register
3.8 XRI 8-bit XRI 6A X-OR 8-bit data with contents of A register
1 MOV A,B 1 OF - - -
2 MVI A, 50H 2 OF MR - -
3 LDA 5000H 4 OF MR MR MR
4 STA 5000H 4 OF MR MR MW
5 IN 80H 3 OF MR IOR -
• The OF cycle takes 4 T-states for completion. The first 3 T-states are
used to fetch the opcode and the last T-state is used to decode and
execute the opcode.
The µP store the data on the A/D bus to Accumulator according to the
6
T3 decoded instruction.
7 The µP makes the RD line HIGH to disable I/O Read.
The µP sends the data on the A/D bus to the output port specified in
6
T3 the decoded instruction.
7 The µP makes the WR line HIGH to disable I/O Write.