Microprocessor and Microcontroller Based Systems (For Cse & It)
Microprocessor and Microcontroller Based Systems (For Cse & It)
INTRODUCTION TO 8085
8085 Microprocessor - Architecture and its operation, Concept of instruction execution and timing
diagrams, fundamentals of memory interface - Addressing modes
– Microprocessor is a silicon chip which includes ALU, register circuits & control
circuits
What is micro?
These devices performed the required operation, but were too large and too
slow.
What is a microprocessor?
As a Programmable device:
• The microprocessor can perform different sets of operations on the data it receives
depending on the sequence of instructions supplied in the given program.
• They processed information 8-bits at a time. That’s why they are called “8-bit
processors”. They can handle large numbers, but in order to process these
numbers, they broke them into 8-bit pieces and processed each group of 8-bits
separately.
What is memory?
– Memory is the location where information is kept while not in current use. It is
stored in memory
– Memory is a collection of storage devices. Usually, each storage device holds one
bit. Also, in most kinds of memory, these storage devices are grouped into
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
groups of 8. These 8 storage locations can only be accessed together. So, one
can only read or write in terms of bytes to and form memory.
– The microprocessor reads (brings in) the data from memory when it needs it and
writes (stores) the results into memory when it is done.
A MICROPROCESSOR-BASED SYSTEM
From the above description, we can draw the following block diagram to represent a
microprocessor-based system as shown in fig 1
In this system, the microprocessor is the master and all other peripherals
are slaves. The master controls all peripherals and initiates all operations. The buses
are group of lines that carry data, address or control signals. The CPU interface is
provided to demultiplex the multiplexed lines, to generate the chip select signals and
additional control signals. The system bus has separate lines for each signal.
All the slaves in the system are connected to the same system bus. At any
time instant communication takes place between the master and one of the slaves. All
the slaves have tristate logic and hence normally remain in high impedance state. The
processor selects a slave by sending an address. When a slave is selected, it comes to
the normal logic and communicates with the processor.
The EPROM memory is used to store permanent programs and data. The
RAM memory is used to store temporary programs and data. The input device is used
to enter program, data and to operate system. The output device is also used for
examining the results. Since the speed of IO devices does not match with speed of
microprocessor, an interface device is provided between system bus and IO device.
The CPU consists of ALU (Arithmetic and Logic Unit), Register unit and control
unit. The CPU retrieves stored instructions and data word from memory; it also deposits
processed data in memory.
This section performs computing functions on data. These functions are arithmetic
operations such as additions subtraction and logical operation such as AND, OR rotate
etc. Result are stored either in registers or in memory or sent to output devices.
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
b) REGISTER UNIT:
It contains various register. The registers are used primarily to store data temporarily
during the execution of a program. Some of the registers are accessible to the uses
through instructions.
c) CONTROL UNIT:
It provides necessary timing & control signals necessary to all the operations in the
microcomputer. It controls the flow of data between the p and peripherals (input, output
& memory). The control unit gets a clock which determines the speed of the p.
o It provides states, control, and timing signals that the memory and
input/output section can use.
Address Bus:
It is a group of wires or lines that are used to transfer the addresses of Memory or
I/O devices. It is unidirectional. In Intel 8085 microprocessor, Address bus was of 16
bits. This means that Microprocessor 8085 can transfer maximum 16 bit address which
means it can address 65,536 different memory locations. This bus is multiplexed with 8
bit data bus. So the most significant bits (MSB) of address goes through Address bus
(A7-A0) and LSB goes through multiplexed data bus (AD0-AD7).
Data Bus:
Control Bus:
Microprocessor uses control bus to process data that is what to do with the
selected memory location. Some control signals are Read, Write and Opcode fetch etc.
Various operations are performed by microprocessor with the help of control bus. This is
a dedicated bus, because all timing signals are generated according to control signal.
The microprocessor is the master, which controls all the activities of the system. To
perform a specific job or task, the microprocessor has to execute a program stored in
memory. The program consists of a set of instructions stored in consecutive memory
location. In order to execute the program the microprocessor issues address and control
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
signals, to fetch the instruction and data from memory one by one. After fetching each
instruction it decodes the instruction and carries out the task specified by the instruction.
Memory
To execute a program:
• The user enters its instructions in binary format into the memory.
• The microprocessor then reads these instructions and whatever data is needed
from memory, executes the instructions and places the results either in memory
or produces it on an output device.
• The microprocessor fetches each instruction, decodes it, and then executes it.
This sequence is continued until all instructions are performed.
The 8085 (from Intel) is an 8-bit microprocessor. The 8085 uses a total of
246 bit patterns to form its instruction set. These 246 patterns represent only 74
instructions. The reason for the difference is that some (actually most) instructions have
multiple different formats. Because it is very difficult to enter the bit patterns correctly,
they are usually entered in hexadecimal instead of binary.
For example, the combination 0011 1100 which translates into “increment the number in
the register called the accumulator”, is usually entered as 3C.
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
Assembly Language
Entering the instructions using hexadecimal is quite easier than entering the binary
combinations. However, it still is difficult to understand what a program written in
hexadecimal does. So, each company defines a symbolic code for the instructions.
The mnemonic for each instruction is usually a group of letters that suggest the
operation performed.
Features of 8085
Address Bus:The most significant 8 bits of the memory address or the 8 bits of the I/0
address,3 stated during Hold and Halt modes.
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
Multiplexed Address/Data Bus; Lower 8 bits of the memory address (or I/0 address)
appear on the bus during the first clock cycle of a machine state. It then becomes the
data bus during the second and third clock cycles. 3 stated during Hold and Halt
modes.
It occurs during the first clock cycle of a machine state and enables the address to get
latched into the on chip latch of peripherals. The falling edge of ALE is set to guarantee
setup and hold times for the address information. ALE can also be used to strobe the
status information. ALE is never 3stated.
SO, S1 (Output)
Data Bus Status. Encoded status of the bus cycle: S1 S0 0 0 HALT 0 1 WRITE 1 0
READ 1 1 FETCH S1 can be used as an advanced R/W status.
RD (Output 3state)
READ: indicates the selected memory or 1/0 device is to be read and that the Data Bus
is available for the data transfer.
WR (Output 3state)
WRITE: Indicates the data on the Data Bus is to be written into the selected memory
or 1/0 location. Data is set up at the trailing edge of WR. 3 stated during Hold and Halt
modes.
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)
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
It 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 stated.
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.
INTR (Input)
INTA (Output)
INTERRUPT ACKNOWLEDGE: is used instead of (and has the same timing as) RD
during the Instruction cycle after an INTR is accepted. It can be used to activate the
8259 Interrupt chip or some other interrupt port.
RESTART INTERRUPTS: These three inputs have the same timing as INTR except
they cause an internal RESTART to be automatically inserted. RST 7.5 ~~ Highest
Priority RST 6.5 RST 5.5 Lowest Priority
TRAP (Input)
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
RESET IN (Input)
Reset sets the Program Counter to zero and resets the Interrupt Enable and HLDA
flipflops. 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.
Indicates CPU is being reset also used as a system RESET. The signal is
synchronized to the processor clock.
X1, X2 (Input)
Crystal or R/C network connections to set the internal clock generator X1 can also
be an external clock input instead of a crystal. The input frequency is divided by 2 to
give the internal operating frequency.
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.
SID (Input)
Serial input data line The data on this line is loaded into accumulator bit 7
whenever a RIM instruction is executed.
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
SOD (output)
Serial output data line. The output SOD is set or reset as specified by the SIM
instruction.
– ADDRESS BUS
• Unidirectional
– DATA BUS
• Bidirectional
• Transferring data
– CONTROL BUS
• Synchronization signals
• Timing signals
• Control signal
– Interrupts
The ALU
• In addition to the arithmetic & logic circuits, the ALU includes the accumulator,
which is part of every arithmetic & logic operation.
• Also, the ALU includes a temporary register used for holding data temporarily
during the execution of the operation. This temporary register is not accessible by the
programmer.
Registers
General Purpose Registers
Flag Register
– S (sign flag), Z (zero flag), AC (auxillary carry flag), P (parity flag) & CY (carry flag)
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
Sign Flag
Zero Flag
Carry Flag
10110011
+ 01001101
---------------
00000000
--------------- ---------------
Parity Flag
– The memory this register points to is a special area called the stack.
– The stack is an area of memory used to hold data that will be retreived
soon.
•The address bus has 8 signal lines A8 – A15 which are unidirectional.
•The other 8 address bits are multiplexed (time shared) with the 8 data bits.
So, the bits AD0 – AD7 are bi-directional and serve as A0 – A7 and D0 – D7 at the
same time.
•During the execution of the instruction, these lines carry the address bits during the
early part, then during the late parts of the execution, they carry the 8 data bits.
In order to separate the address from the data, we can use a latch to save the value
before the function of the bits changes.
Demultiplexing AD7-AD0
– From the above description, it becomes obvious that the AD7– AD0 lines are serving
a dual purpose and that they need to be demultiplexed to get all the information.
– The high order bits of the address remain on the bus for three clock periods. However,
the low order bits remain for only one clock period and they would be lost if they are not
saved externally. Also, notice that the low order bits of the address disappear when they
are needed most.
– To make sure we have the entire address for the full three clock cycles, we will use an
external latch to save the value of AD7– AD0 when it is carrying the address bits. We
use the ALE signal to enable this latch.
Demultiplexing AD7-AD0
Given that ALE operates as a pulse during T1, we will be able to latch the
address. Then when ALE goes low, the address is saved and the AD7– AD0 lines can
be used for their purpose as the bi-directional data lines.
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
• The high order address is placed on the address bus and hold for 3 clk periods,
• The low order address is lost after the first clk period, this address needs to be
hold however we need to use latch
• The ALE signal is connected to the enable (G) pin of the latch and the OC –
Output control – of the latch is grounded
ADDRESSING MODES
The microprocessor has different ways of specifying the data for the
instruction. These are called “addressing modes”.
– Implied CMA
– Immediate MVI B, 45
– Indirect LDAX B
Load the accumulator with the contents of the memory location whose address is stored
in the register pair BC).
Many instructions require two operands for execution. For example transfer of
data between two registers. The method of identifying the operands position by the
instruction format is known as the addressing mode. When two operands are involved in
an instruction, the first operand is assumed to be in a register Mp itself.
• Register addressing
• Direct addressing mode
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
Register Addressing
Example LDA 3000H (The content at the location 3000H is copied to the
register A).
Example MOV A, M (Move data from memory location specified by H-L pair to
accumulator)
This mode doesn't require any operand. The data is specified by opcode itself.
Example RAL,
CMP
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
Instruction Size
• Depending on the operand type, the instruction may have different sizes. It will
occupy a different number of memory bytes.
– The exception is any instruction that contains immediate data or a memory address.
– One for the opcode and the other for the 8-bit data.
– One for the opcode, and the other two for the 16-bit address.
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. Example: MOV B, C
or MOV B, M.
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 H-L registers. Example:
MVI B, 57H or MVI M, 57H.
The contents of a memory location, specified by a 16- bit address in the operand, are
copied to the accumulator. The contents of the source are not altered. Example: LDA
2034H
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. Example: LDAX B
The contents of accumulator are copied into the memory location specified by the
operand. Example: STA 2500 H
The contents of accumulator are copied into the memory location specified by the
contents of the register pair. Example: STAX B
The contents of register L are stored into memory location specified by the 16-bit
address. The contents of register H are stored into the next memory location.
Example: SHLD 2550 H
The contents of register H are exchanged with the contents of register D. The contents
of register L are exchanged with the contents of register E. Example: XCHG
This instruction loads the contents of H-L pair into SP. Example: SPHL
The contents of L register are exchanged with the location pointed out by the contents
of the SP. The contents of H register are exchanged with the next location (SP + 1).
Example: XTHL
H-L contents
The contents of registers H and L are copied into the program counter (PC). The
contents of H are placed as the high-order byte and the contents of L as the low-order
byte. Example: PCHL
The contents of register pair are copied onto stack. SP is decremented and the
contents of high-order registers (B, D, H, A) are copied into stack. SP is again
decremented and the contents of low-order registers (C, E, L, Flags) are copied into
stack. Example: PUSH B
The contents of top of stack are copied into register pair. The contents of location
pointed out by SP are copied to the low-order register (C, E, L, Flags). SP is
incremented and the contents of location are copied to the high-order register (B, D, H,
A). Example: POP H
The contents of accumulator are copied into the I/O port. Example: OUT 78 H
1. ARITHMETIC INSTRUCTIONS
Addition
Any 8-bit number, or the contents of register, or the contents of memory location can be
added to the contents of accumulator. The result (sum) is stored in the accumulator. No
two other 8-bit registers can be added directly. Example: The contents of register B
cannot be added directly to the contents of register C.
The contents of register or memory are added to the contents of accumulator. The
result is stored in accumulator. If the operand is memory location, its address is
specified by H-L pair. All flags are modified to reflect the result of the addition. Example:
ADD B or ADD M
The contents of register or memory and Carry Flag (CY) are added to the contents
of accumulator. The result is stored in accumulator. If the operand is memory location,
its address is specified by H-L pair. All flags are modified to reflect the result of the
addition. Example: ADC B or ADC M
The 8-bit data is added to the contents of accumulator. The result is stored in
accumulator. All flags are modified to reflect the result of the addition. Example: ADI 45
H
The 8-bit data and the Carry Flag (CY) are added to the contents of accumulator.
The result is stored in accumulator. All flags are modified to reflect the result of the
addition. Example: ACI 45 H
The 16-bit contents of the register pair are added to the contents of H-L pair. The result
is stored in H-L pair. If the result is larger than 16 bits, then CY is set.No other flags are
changed. Example: DAD B
Subtraction
Any 8-bit number, or the contents of register, or the contents of memory location can be
subtracted from the contents of accumulator.The result is stored in the
accumulator.Subtraction is performed in 2’s complement form. If the result is negative, it
is stored in 2’s complement form. No two other 8-bit registers can be subtracted directly.
The contents of the register or memory location are subtracted from the contents of the
accumulator. The result is stored in accumulator. If the operand is memory location, its
address is specified by H-L pair. All flags are modified to reflect the result of subtraction.
Example: SUB B or SUB M
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. If
the operand is memory location, its address is specified by H-L pair. All flags are
modified to reflect the result of subtraction. Example: SBB B or SBB M
The 8-bit data is subtracted from the contents of the accumulator.The result is stored in
accumulator. All flags are modified to reflect the result of subtraction. Example: SUI 45
H
The 8-bit data and the Borrow Flag (i.e. CY) is subtracted from the contents of the
accumulator. The result is stored in accumulator.All flags are modified to reflect the
result of subtraction. Example: SBI 45 H
Increment/Decrement
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
The contents of register or memory location are incremented by 1. The result is stored
in the same place. If the operand is a memory location, its address is specified by the
contents of H-L pair. Example: INR B or INR M
The contents of register pair are incremented by 1. The result is stored in the same
place. Example: INX H
The contents of register or memory location are decremented by 1. The result is stored
in the same place. If the operand is a memory location, its address is specified by the
contents of H-L pair. Example: DCR B or DCR M
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
The contents of register pair are decremented by 1. The result is stored in the same
place. Example: DCX H
2. LOGICAL INSTRUCTIONS
These instructions perform logical operations on data stored in registers, memory and
status flags. The logical operations are:
• AND
• OR
• XOR
• Rotate
• Compare
• Complement
Any 8-bit data, or the contents of register, or memory location can logically have
• AND operation
• OR operation
• XOR operation
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 the 8-bit data. The result is
placed in the accumulator. S, Z, P are modified to reflect the result.CY is reset, AC is
set. Example: ANI 86H.
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.S, Z, P are modified to reflect the
result. CY and AC are reset. Example: ORA B or ORA M.
accumulator
The contents of the accumulator are logically ORed with 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.
The contents of the accumulator are XORed 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. S, Z, P are modified to reflect the
result of the operation. CY and AC are reset. Example: XRA B or XRA M.
The contents of the accumulator are XORedwith 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: XRI 86H.
Rotate
Each bit in the accumulator can be shifted either left or right to the next position as
shown in fig5.
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. Example: RLC.
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. Example: RRC.
Each binary bit of the accumulator is rotated left by one position through the
Carry flag as shown in fig 6. 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 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. Example:
RAR.
COMPARE
Any 8-bit data, or the contents of register, or memory location can be compares for:
• Equality
• Greater Than
• Less Than
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:
The 8-bit data is compared with the contents of accumulator.The values being
compared remain unchanged. The result of the comparison is shown by setting the
flags of the PSW as follows:
COMPLEMENT
The contents of the accumulator are complemented. No flags are affected. Example:
CMA.
The Carry flag is complemented. No other flags are affected. Example: CMC.
The Carry flag is set to 1. No other flags are affected. Example: STC.
3. BRANCHING INSTRUCTIONS
The branching instruction alters the normal sequential flow. These instructions alter
either unconditionally or conditionally.
Branch operations are of two types:
Unconditional branch-- Go to a new location no matter what.
Conditional branch-- Go to a new location if the condition is true.
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
The program sequence is transferred to the memory location specified by the 16-bit
address given in the operand.
Example: JMP 2034 H.
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. Replace x with
condition
Example: JZ 2034 H.
Jump conditionally
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.
Example: CALL 2034 H.
Opcode Operand Description
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. Before the
transfer, the address of the next instruction after the call (the contents of the program
counter) is pushed onto the stack. Replace x with condition
Example: CZ 2034 H.
Call Conditionally
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.
Opcode Operand Description
The program sequence is transferred from the subroutine to the calling program based
on the specified flag of the PSW. 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. Replace x with condition
RETURN CONDITIONALLY
The RST instruction jumps the control to one of eight memory locations depending upon
the number. These are used as software instructions in a program to transfer program
execution to one of the eight locations. Example: RST 3.
RESTART Address table
Instructions Restart address
RST 0 0000 H
RST 1 0008 H
RST 2 0010 H
RST 3 0018 H
RST 4 0020 H
RST 5 0028 H
RST 6 0030 H
RST 7 0038 H
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
The interrupt enable flip-flop is reset and all the interrupts except the TRAP are
disabled.
No flags are affected.
Example: DI
Opcode Operand Description
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
Operand Description
Opcode
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.
Example: RIM
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
RIM Instruction
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.
Example: SIM
SIM Instruction
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
TIMING DIAGRAM
Timing diagram is the display of initiation of read/write and transfer of data operations
under the control of 3-status signals IO / M, S1, and S0. All actions in the
microprocessor are controlled by either leading or trailing edge of the clock.
,
Machine Cycle
It is the time required by the microprocessor to complete the operation of accessing the
memory devices or I/O devices. In machine cycle various operations like opcode fetch,
memory read, memory write, I/O read, I/O write are performed.
T-State
Each machine cycle is composed of many clock cycles. Since, the data and
instructions, both are stored in the memory, the µP performs fetch operation to read the
instruction or data and then execute the instruction. The 3-status signals: IO / M, S1,
and S0 are generated at the beginning of each machine cycle. The unique combination
of these 3-status signals identify read or write operation and remain valid for the
duration of the cycle.
Table 1 Machine Cycle Status And Control Signals
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
Table1 shows details of the unique combination of these status signals to identify
different machine cycles. Thus, time taken by any µP to execute one instruction is
calculated in terms of the clock period. The execution of instruction always requires
read and writes operations to transfer data to or from the µP and memory or I/O
devices. Each read/ write operation constitutes one machine cycle (MC1) as indicated in
Fig.7. Each machine cycle consists of many clock periods/ cycles, called T-states.
Processor Cycle:
The functions of the microprocessor are divided into fetch and execute cycle of
any instruction of a program. The program is nothing but number of instructions stored
in the memory in sequence. In the normal process of operation, the microprocessor
fetches (receives or reads) and executes one instruction at a time in the sequence until
it executes the halt (HLT) instruction.
Instruction Cycle
• Fetch, and
• Execute.
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
The time taken by the µP in performing the fetch and execute operations are
called fetch and execute cycle. Thus, sum of the fetch and execute cycle is called the
instruction cycle as indicated in Fig. 8. Each read or writes operation constitutes a
machine cycle. The instructions of 8085 require 1–5 machine cycles containing 3–6
states (clocks). The 1st machine cycle of any instruction is always an Op Code fetch
cycle in which the processor decides the nature of instruction. It is of at least 4-states. It
may go up to 6-states.
• If the addressing mode is indirect then No. of machine cycles = No. of bytes + 1.
Add +1 to the No. of machine cycles if it is memory read/write operation.
• If the operand is 8-bit or 16-bit address then, No. of machine cycles = No. of bytes
+1.
The process of Opcode fetch operation requires minimum 4-clock cycles T1, T2,
T3, and T4 and is the 1st machine cycle (M1) of every instruction.
Example
SEC1312 MICROPROCESSOR AND MICROCONTROLLERBASED SYSTEMS
UNIT 1 PREPARED BY: DR. BETTY MARTIN
For fetching a byte, the microprocessor must find out the memory location where it is
stored. Then provide condition (control) for data flow from memory to the
microprocessor. The process of data flow and timing diagram of fetch operation are
shown in Fig. 9. The microprocessor fetches Opcode of the instruction from the memory
as per the sequence below
The MVI B, 05H instruction requires 2-machine cycles (M1 and M2). M1 requires
4-states and M2 requires 3-states, total of 7-states as shown in Fig. 10. Status signals
IO/M, S1 and S0 specifies the 1st machine cycle as the op-code fetch. In T1-state, the
high order address {10H} is placed on the bus A15 ⇔ A8 and low-order address {00H}
on the bus AD7 ⇔ AD0 and ALE = 1. In T2 -state, the RD line goes low and the data 06
H from memory location 1000H are placed on the data bus. The fetch cycle becomes
complete in T3-state. The instruction is decoded in the T4-state. During T4-state, the
contents of the bus are unknown. With the change in the status signal, IO/M = 0, S1 = 1
and S0 = 0, the 2nd machine cycle is identified as the memory read. The address is
1001H and the data byte [05H] is fetched via the data bus. Both M1 and M2 perform
memory read operation, but the M1 is called op-code fetch i.e., the 1st machine cycle of
each instruction is identified as the opcode fetch cycle.
Operation:
Operation:
Operation:
Operation: