P6 Notes
P6 Notes
P6 Notes
Sc (CBCS) - Paper VI
MICROPROSSESOR & Electronic Instrumentation (EL-502T)
Introduction:
The word Microprocessor comes from the combination of micro and processor. Processor
means a device that processes whatever. In this context processor means a device that
processes numbers, specifically binary numbers, 0’s and 1’s. To process means to
manipulate. It is a general term that describes all manipulation. Again in this content, it
means to perform certain operations on the numbers that depend on the microprocessor’s
design.
In the late 1960’s, processors were built using discrete elements. These devices performed
the required operation, but were too large and too slow. In the early 1970’s the microchip was
invented. All of the components that made up the processor were now placed on a single
piece of silicon. The size became several thousand times smaller and the speed became
several hundred times faster. The “Micro” Processor was born.
Microprocessor based system:
Figure shows the block diagram of a microprocessor based system. It consists of Input,
Output, Memory and processor.
Memory: Memory stores information such as instructions and data in binary format (0 and
1). It provides this information to the microprocessor whenever it is needed. Usually, there is
a memory “sub-system” in a microprocessor-based system.
This sub-system includes: The registers inside the microprocessor
Read Only Memory (ROM) used to store information that does not change.
Random Access Memory (RAM) (also known as Read/Write Memory) used to store
information supplied by the user. Such as programs and data.
Memory Map and Addresses: The memory map is a picture representation of the address
range and shows where the different memory chips are located within the address range.
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 three cycle instruction execution model
To execute a program, the microprocessor “reads” each instruction from memory,
“interprets” it, then “executes” it. The microprocessor fetches each instruction, decodes it,
Then executes it. This sequence is continued until all instructions are performed.
Machine Language
The number of bits that form the “word” of a microprocessor is fixed for that particular
processor. These bits define a maximum number of combinations. For example an 8-bit
microprocessor can have at most 28 = 256 different combinations. However, in most
microprocessors, not all of these combinations are used. Certain patterns are chosen and
assigned specific meanings. Each of these patterns forms an instruction for the
microprocessor. The complete set of patterns makes up the microprocessor’s machine
language.
The 8085 Machine Language
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.
Basic Concepts of Microprocessors
Microcomputer Microprocessor Microcontroller
A computer with a Silicon chip which includes Silicon chip which
microprocessor as its CPU, ALU, register circuits & includes microprocessor,
includes memory, I/O etc. control circuits memory & I/O in a single
package
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.
These codes are called “mnemonics”. The mnemonic for each instruction is usually a group
of letters that suggest the operation performed.
Using the previous example, 0011 1100 translates to 3C in hexadecimal (OPCODE). Its
mnemonic is: “INR A”. INR stands for “increment register” and A is short for accumulator.
Example: 1000 0000, Which translates to 80 in hexadecimal. Its mnemonic is “ADD B”.
“Add register B to the accumulator and keep the result in the accumulator”.
It is important to remember that a machine language and its associated assembly language are
completely machine dependent. In other words, they are not transferable from one
microprocessor to a different one.
For example, Motorola has an 8-bit microprocessor called the 6800.The 8085 machine
language is very different from that of the 6800. So is the assembly language. A program
written for the 8085 cannot be executed on the 6800 and vice versa.
“Assembling” the Program: How does assembly language get translated into machine
language? There are two ways: First one is “hand assembly”. The programmer translates
each assembly language instruction into its equivalent hexadecimal code (machine language).
Then the hexadecimal code is entered into memory.
In the other possibility is a program called an “assembler”, which does the translation
automatically.
8085 Microprocessor Architecture: 8085 is an 8-bit general purpose microprocessor
capable of addressing 65536 bytes (64 k) of memory, having 40 pins. It requires +5 v power
supply and can operate with 3 MHz clock. 8085 is upward compatible. Figure shows the pin
configuration of 8085A microprocessor.
Auxillary Carry Flag (AC): This flag is set if there is a carry out of bit-3. Used in BCD
number operations.
Parity Flag (P): It is updated based on the number of one’s in a given byte of the data. If
even number of one’s then even parity else odd parity. Is set if parity is even (P=1) and is
cleared if parity is odd (P=0).
Program Counter (PC): This is a register that is used to control the sequencing of the
execution of instructions. This register always holds the address of the next instruction to be
fetched in the program. Since it holds an address, it is of 16-bit wide.
Stack Pointer (SP): The stack pointer is also a 16-bit register that is used to point into
memory. 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 retrieved soon. The stack is usually accessed in
a Last In First out (LIFO) fashion.
Non Programmable Registers: Instruction Register (IR) & Decoder Instruction is stored in
IR after fetched by processor Decoder decodes instruction in IR.
Internal Clock generator: 8085 processor uses clock frequency of 3.125 MHz internally
and 6.25 MHz externally.
Address and Data Busses: The address bus has 8 signal lines A8 –A15which 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 –D7at the same time. During
the execution of the instruction, these lines carry the address bits during the early part and
during the late parts of the execution they carry the 8-bit data. In order to separate the address
from the data, a latch is used to save the value of the data 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.
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. The high order address is placed on the address bus and hold
for 3 clock periods. The low order address is lost after the first clock period, this address
needs to be hold however we need to use latch. The address AD7 –AD0 is connected as inputs
to the latch 74LS373. The ALE signal is connected to the enable (G) pin of the latch and the
OC –Output control –of the latch is grounded.
8085 BUS Structure: There are three types of wire connections in the processor 8085 to
carry out various operations.
Address Bus: It is a 16-bit address lines A0-A15. This can have 0000H to FFFFH address
locations and can access 65536 bytes (64KB = 216) of memory. It is used to map I/O and uses
same instructions to accessing I/O devices and also memory.
Data Bus: It is an 8-bit data lines AD0-AD7. It is bi directional bus. The data bits are moved to
and from MPU to I/O and vice versa. The data range is from 00H to FFH (0 to 255)
Control Bus: It is usually a single bit line sending the generated control signals such as
read/write enable or flag bits from the processor to various peripherals. It is Unidirectional.
Address Bus: Consists of 16 address lines : A0 – A15. This can access 64KB ( = 216 =
65535) bytes of memory. Address locations is from 0000H to FFFFH. Use memory to map
I/O, same instructions used to access I/O devices and memory.
Data Bus: Consists of 8- data lines D0-D7. Operates in Bidirectional mode. The data bits are
sent from microprocessor unit to I/O and vice versa. Data ranges from 00H to FFH.
Control Bus: Consists of various lines carrying the control signals such as Read, Write,
Enable, Flag bits etc.
One Byte Instructions: One byte instruction includes the opcode and operand in the same
byte. The operands are internal registers and are coded into the instruction. Example: MOV
Rd, Rs In this instruction Rd and Rs are two internal registers. Data which is available in Rs
register is loaded to Rd register. Only the Rd register content is modified.
AB AB 00 00
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.
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.
INCREMENT / DECREMENT
• The 8-bit contents of a register or a memory location can be incremented
or decremented by 1.
• The 16-bit contents of a register pair can be incremented or decremented
by 1.
• Increment or decrement can be performed on any register or a memory
location.
Opcode Operand Description
ADD R Add register or memory to accumulator
M
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
Opcode Operand Description
ADC R Add register or memory to accumulator
M with carry
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
Opcode Operand Description
ADI 8-bit data Add immediate to accumulator
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
Opcode Operand Description
ACI 8-bit data Add immediate to accumulator with
carry
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
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
AND, OR, XOR:
• Any 8-bit data, or the contents of register, or memory location can
logically have
– AND operation
– OR operation
– XOR operation with the contents of accumulator.
• The result is stored in accumulator.
Rotate:
• Each bit in the accumulator can be shifted either left or right to the next
position.
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.
• The result is reflected in status flags.
Complement:
• The contents of accumulator can be complemented.
• Each 0 is replaced by 1 and each 1 is replaced by 0.
Opcode Operand Description
CMP R Compare register or memory with accumulator
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 (Z=1)
if (A) > (reg/mem): carry and zero flags are reset. (CY=Z=0)
Example: CMP B or CMP M
Opcode Operand Description
CPI 8-bit data Compare immediate with accumulator
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:
if (A) < data: carry flag is set (CY=1)
if (A) = data: zero flag is set (Z=1)
if (A) > data: carry and zero flags are reset (CY=Z-0)
Example: CPI 89H
Opcode Operand Description
ANA R Logical AND register or memory with
M accumulator
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.
Opcode Operand Description
ANI 8-bit data Logical AND immediate with
accumulator
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.
Opcode Operand Description
XRA R Exclusive OR register or memory with
M accumulator
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.
Opcode Operand Description
ORA R Logical OR register or memory
M with accumulator
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.
Opcode Operand Description
ORI 8-bit data Logical OR immediate with 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.
Opcode Operand Description
XRA R Logical XOR register or memory with
M accumulator
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.
Opcode Operand Description
XRI 8-bit data XOR immediate with accumulator
The contents of the accumulator are XORed 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: XRI 86H.
Opcode Operand Description
RLC None Rotate accumulator left
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.
CY D7 D6 D5 D4 D3 D2 D1 D0
CY D7 D6 D5 D4 D3 D2 D1 D0
CY D7 D6 D5 D4 D3 D2 D1 D0
CY D7 D6 D5 D4 D3 D2 D1 D0
Branching Instructions:
• The branching instruction alter the normal sequential flow.
• These instructions alter either unconditionally or conditionally.
Opcode Operand Description
JMP 16-bit Jump unconditionally
address
The program sequence is transferred to the memory location specified by
the 16-bit address given in the operand.
Example: JMP 2034 H.
Opcode Operand Description
Jx 16-bit address Jump conditionally
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.
Example: JZ 2034 H.
Opcode Description Status Flags
JC Jump if Carry CY = 1
JNC Jump if No Carry CY = 0
JP Jump if Positive S=0
JM Jump if Minus S=1
JZ Jump if Zero Z=1
JNZ Jump if No Zero Z=0
JPE Jump if Parity Even P=1
JPO Jump if Parity Odd P=0
CC Call if Carry CY = 1
CNC Call if No Carry CY = 0
CP Call if Positive S=0
CM Call if Minus S=1
CZ Call if Zero Z=1
CNZ Call if No Zero Z=0
CPE Call if Parity Even P=1
CPO Call if Parity Odd P=0
Control Instructions:
• The control instructions control the operation of microprocessor.
Opcode Operand Description
NOP None No operation
No operation is performed.
The instruction is fetched and decoded but no operation is executed.
Example: NOP
Opcode Operand Description
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
EI None Enable interrupt
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
Opcode Operand Description
RIM None Read Interrupt Mask
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
Knowing the number of T states an instruction requires to execute, and the time
period of the clock signal Delay in the loop can be calculated as:
Delay = (Number of T states) X (Time period)
For example, MVI instruction needs 7T states. If the processor is running on
2MHz, then to execute MVI instruction processor needs 7x0.5microsecond =
3.5microsecond.
The following is an example of a delay loop:
MVI C, FF 7 T –States
Loop: DCR C 4 T-States
JNZ Loop 10 T-States
The first instruction initialises the loop counter and is executed only once
requiring only 7 T-States. The following two instructions form a loop that
requires 14 T-states to execute and is repeated 255 times until register C
becomes 0. In this program segment last iteration JNZ will fail an require only 7
T-states rather than 10 T-states. Hence, to find the total delay 3 T-states must be
deducted from the total delay to get an accurate delay calculation. Total delay is
given by the formula: Tdelay = TO +TL where, Tdelay – total delay, TO- delay
outside the loop and TL-delay of the loop.
TO= 7T-States is the delay of the MVI instruction
TL= (14T x 255)-3 = 3567 T-states
Similarly, delay loop can be set up using a register pair as loop counter.
LXI B,1000H 10 T-States
Loop: DCX B 6 T-States
MOV A,C 4 T-States
ORA B 4 T-States
JNZ Loop 10 T-States
TO = 10 T-States
TL = (24T x 4096)-3T=98301 T-States
Nested Loops: To increase the total delay nested loops can be setup in
assembly language by using two registers for the two loop counters and
updating the right register in the right loop. Figure shows the flowchart for the
nested loops.
The Stack
The stack is an area of memory identified by the programmer for
temporary storage of information.
The stack is a LIFO structure. Last In First Out. The stack normally
grows backwards into memory. In other words, the programmer defines the
bottom of the stack and the stack grows up into reducing address range.
Given that the stack grows backwards into memory, it is customary to place the
bottom of the stack at the end of memory to keep it as far away from user
programs as possible.
•In the 8085, the stack is defined by setting the SP (Stack Pointer) register.
LXI SP, FFFFH
This sets the Stack Pointer to location FFFFH (end of memory for the 8085).
It is possible to push the PSW onto the stack, do whatever operations are
needed, then POP it off of the stack.The result is that the contents of the
Accumulator and the status of the Flags are returned to what they were before
the operations were executed.
Subroutines
Asubroutineisagroupofinstructionsthatwillbeusedrepeatedlyindifferentloc
ationsoftheprogram.Ratherthanrepeatthesameinstructionsseveraltimes,theycanbe
groupedintoasubroutinethatiscalledfromthedifferentlocations.
InAssemblylanguage,asubroutinecanexistanywhereinthecode.However,iti
scustomarytoplacesubroutinesseparatelyfromthemainprogram.
Subroutines
The 8085 has two instructions for dealing with subroutines.The CALL
instruction is used to redirect program execution to the subroutine.
The RTE insutruction is used to return the execution to the calling
routine.
Cautions
The CALL instruction places the return address at the two memory
locations immediately before where the Stack Pointer is pointing.You must set
the SP correctly BEFORE using the CALL instruction.
The RTE instruction takes the contents of the two memory locations at
the top of the stack and uses these as the return address.Do not modify the stack
pointer in a subroutine. You will loose the return address.
If this is not desired, the subroutine should PUSH all the registers it needs
on the stack on entry and POP them on return.The original values are restored
before execution returns to the calling program.
A Proper Subroutine
According to Software Engineering practices, a proper subroutine:Is only
entered with a CALL and exited with an RTE
Has a single entry pointDo not use a CALL statement to jump into
different points of the same subroutine.
Has a single exit pointThere should be one return statement from any
subroutine.
Following these rules, there should not be any confusion with PUSH and
POP usage.
Interrupts
Interrupt is a process where an external device can get the attention of the
microprocessor.The process startsfrom the I/O device
The process is asynchronous.
Responding to Interrupts
Responding to an interrupt may be immediateor delayeddepending on
whether the interrupt is maskable or non-maskable and whether interrupts are
being masked or not.
There are two ways of redirecting the execution to the ISR depending on
whether the interrupt is vectored or non-vectored.The vector is already knownto
the Microprocessor
The device will have to supplythe vector to the Microprocessor
RST 5.5, RST 6.5, RST 7.5 are all automatically vectored.RST 5.5, RST
6.5, and RST 7.5 are all maskable.
1. When the microprocessor executes the RST instruction received from the
device, it saves the address of the next instructionon the stack and jumps to the
appropriate entry in the IVT.
2. The IVT entry must redirect the microprocessor to the actual service
routine.
3. The service routine must include the instruction EIto re-enable the
interrupt process.
4. At the end of the service routine, the RETinstruction returns the execution
to where the program was interrupted.
In the 2nd and 3rd machine cycles:the 16-bit address of the next
instruction is saved on the stack.
Then the microprocessor jumps to the address associated with the
specified RST instruction.
The location in the IVT associated with the RST instruction can not hold
the complete service routine.The routine is written somewhere else in memory.
Only a JUMP instruction to the ISR’s location is kept in the IVT block.
The 3 outputs carry the index of the highest priority active input.
Figure 12.4 in the book shoes how this circuit can be used with a Tri-state
buffer to implement an interrupt priority scheme.The figure in the textbook does
not show the method for distributing the INTA signal back to the individual
devices.
Note that the opcodes for the different RST instructions follow a set
pattern.Bit D5, D4 and D3 of the opcodes change in a binary sequence from
RST 7 down to RST 0.
The other bits are always 1.
This allows the code generated by the 74366 to be used directly to choose
the appropriate RST instruction.
•The one draw back to this scheme is that the only way to change the
priority of the devices connected to the 74366 is to reconnect the hardware.
The 8085 Maskable/Vectored Interrupts
The 8085 has 4 Masked/Vectored interrupt inputs.RST 5.5, RST 6.5, RST
7.5They are all maskable.
They are automatically vectoredaccording to the following table:The
vectors for these interrupt fall in between the vectors for the RST instructions.
That’s why they have names like RST 5.5 (RST 5 and a half).
Through individual mask flip flops that control the availability of the
individual interrupts.These flip flops control the interrupts individually.
The 8085 Maskable/Vectored Interrupt Process
1. The interrupt process should be enabledusing the EIinstruction.
2. The 8085 checks for an interrupt during the execution of everyinstruction.
3. If there is an interrupt, and if the interrupt is enabled using the interrupt
mask, the microprocessor will complete the executing instruction, and reset the
interrupt flip flop.
4. The microprocessor then executes a call instruction that sends the
execution to the appropriatelocation in the interrupt vector table.
When the microprocessor executes the call instruction, it saves the address of
the next instructionon the stack.
6.The microprocessor jumps to the specific service routine.
7.The service routine must include the instruction EIto re-enable the interrupt
process.
8.At the end of the service routine, the RETinstruction returns the execution to
where the program was interrupted.
The Interrupt Enable flip flop is manipulated using the EI/DI instructions.
•The individual masksfor RST 5.5, RST 6.5 and RST 7.5 are manipulated
using the SIMinstruction.This instruction takes the bit pattern in the
Accumulator and applies it to the interrupt mask enabling and disabling the
specific interrupts.
Bit 0 is the maskfor RST 5.5, bit 1 is the maskfor RST 6.5 and bit 2 is the
maskfor RST 7.5.If the mask bit is 0, the interrupt is available.
If the mask bit is 1, the interrupt is masked.
•Bit 3 (Mask Set Enable -MSE) is an enable for setting the mask.If it is
set to 0 the mask is ignoredand the old settings remain.
If it is set to 1, the new setting are applied.
The SIM instruction is used for multiple purposes and not only for setting
interrupt masks.It is also used to control functionality such as Serial Data
Transmission.
Therefore, bit 3 is necessary to tell the microprocessor whether or not
the interrupt masks should be modified
The RST 7.5 interrupt is the only8085 interrupt that has memory.If a
signal on RST7.5 arrives while it is masked, a flip flop will remember the
signal.
When RST7.5 is unmasked, the microprocessor will be interrupted even
if the device has removed the interrupt signal.
This flip flop will be automatically resetwhen the microprocessor
responds to an RST 7.5 interrupt.
•Bit 4 of the accumulator in the SIM instruction allows
explicitlyresettingthe RST 7.5 memory even if the microprocessor did not
respond to it.
The SIM instruction can also be used to perform serial data transmission
out of the 8085’s SOD pin.One bit at a time can be sent out serially over the
SOD pin.
Triggering Levels
RST 7.5 is positive edge sensitive.When a positive edge appears on the
RST7.5 line, a logic 1 is storedin the flip-flop as a “pending” interrupt.
Since the value has been stored in the flip flop, the line does not have to
be highwhen the microprocessor checks for the interrupt to be recognized.
The line must go to zero and back to onebefore a new interrupt is
recognized.
RST 6.5 and RST 5.5 are level sensitive.The interrupting signal must
remain present until the microprocessor checks for interrupts.
•Bit 7 is used for Serial Data Input.The RIM instruction reads the value of
the SID pinon the microprocessor and returns it in this bit.
Pending Interrupts
Since the 8085 has five interrupt lines, interrupts may occur during an
ISR and remain pending.Using the RIMinstruction, the programmer can read
the status of the interrupt lines and find if there are any pending interrupts.
The advantage is being able to find about interrupts on RST 7.5, RST 6.5,
and RST 5.5 without having to enable low level interrupts like INTR.
Assume the RST5.5 and RST7.5 are enabled and the interrupt process is
disabled.
TRAP
TRAP is the only non-maskableinterrupt.It does not need to be enabled
because it cannot be disabled.
However, TRAP has lower priority than the HLD signal used for DMA.
Memory and I/O Interfacing:
• Interface is a concept that refers to a point of interaction between
components, and is applicable at the level of both hardware and software.
• This allows a component, (such as a graphics card or an Internet
browser), to function independently while using interfaces to
communicate with other components via an input/output system and an
associated protocol.
• Address Bus
– Used to address memory & I/O devices
– 8085 has a 16-bit address bus
• Data Bus
– Used to transfer instructions and data
– 8085 has a 8-bit data bus
–
Higher Order Address Bus:
• The higher order address bus is a unidirectinal bus.
• It carries most significant 8-bits of a 16-bit address of memory or I/O
device.
• Address remains on lines as long operation is not completed.
Lower Order Address/Data Bus:
•
In case of multiple chips simple circuit like NOT gate will not work.
• In this case normally decoder circuits like 3-to-8 decoder circuit 74LS138
are used.
• These circuit are called address decoders.
8085
CS
A15-A8
ALE
A9- A0 1K Byte
AD7-AD0 Latch Memory
A7- A0 Chip
WR RD IO/M D7- D0
RD WR
3. Modem Control:
DSR - Data Set Ready : Checks if the Data Set is ready when
communicating with a modem.
DTR - Data Terminal Ready : Indicates that the device is ready to accept
data when the 8251 is communicating with a modem.
CTS - Clear to Send : If its low, the 8251A is enabled to transmit the
serial data provided the enable bit in the command byte is set to ‘1’.
RTS - Request to Send Data : Low signal indicates the modem that the
receiver is ready to receive a data byte from the modem.
4. Transmitter Section:
Accepts parallel data from MPU & converts them into serial data.
Has two registers:
– Buffer register : To hold eight bits
– Output register : To convert eight bits into a stream of serial bits.
5. Receiver Section:
Accepts serial data on the RxD pin and converts them to parallel data.
Has two registers :
a. Receiver input register
b. Buffer register
When RxD goes low, the control logic assumes it is a start bit, waits for
half bit time, and samples the line again. If the line is still low, the input
register accepts the following data, and loads it into buffer register at the
rate determined by the receiver clock.
RxRDY - Receiver Ready Output: Output signal, goes high when the
USART has a character in the buffer register & is ready to transfer it to
the MPU.
RxD - Receive Data Input : Bits are received serially on this line &
converted into a parallel byte in the receiver input register.
RxC - Receiver Clock Input : Clock signal that controls the rate at
which bits are received by the USART.
• RESET: This is used to reset the device. That means clear control
registers.
• PA0-PA7:It is the 8-bit bi-directional I/O pins used to send the data to
peripheral or to receive the data from peripheral.
• PB0-PB7:Similar to PA
• PC0-PC7:This is also 8-bit bidirectional I/O pins. These lines are divided
into two groups.
1. PC0 to PC3(Lower Groups)
2. PC4 to PC7 (Higher groups)
These two groups working in separately using 4 data’s.
Block Diagram of 8255:
ARITHMETIC INSTRUCTIONS
Add register or memory to accumulator
ADD R The contents of the operand (register
or memory) are M added to the
contents of the accumulator and the
result is stored in the accumulator. If
Example: ADD B or the operand is a memory location, its
ADD M 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 The contents of the operand (register
or memory) and M the Carry flag are
added to the contents of the
accumulator and the result is stored in
the accumulator. If the operand is a
Example: ADC B or memory location, its location is
ADC M specified by the contents of
the HL registers. All flags are modified
to reflect the result of the addition
LOGICAL INSTRUCTIONS
Compare register or memory with accumulator
CMP R The contents of the operand (register
or memory) are M 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
Example: CMP B or set,CY=1
CMP M if (A) = (reg/mem): zero flag is set,
Z=1
if (A) > (reg/mem): carry and zero
flags are reset, CY=Z=0
Compare immediate with accumulator
CPI 8-bit data The second byte (8-bit data) is
compared with the contents of the
accumulator. The values being
compared remain unchanged. The
result of the comparison is shown by
setting
the flags of the PSW as follows:
if (A) < data: carry flag is set, CY=1
Example: CPI 89 if (A) = data: zero flag is set, Z=1
if (A) > data: carry and zero flags are
reset, CY=Z=0
Logical AND register or memory with accumulator
ANA R The contents of the accumulator are
logically ANDed with M 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
Example: ANA B or specified by the contents of
ANA M 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 The contents of the accumulator are
logically ANDed with the 8-bit data
(operand) and the result is placed in
the
Example: ANI 86 accumulator. S, Z, P are modified to
reflect the result of the operation. CY
is reset. AC is set.
CY D7 D6 D5 D4 D3 D2 D1 D0
CY D7 D6 D5 D4 D3 D2 D1 D0
CY D7 D6 D5 D4 D3 D2 D1 D0
CY D7 D6 D5 D4 D3 D2 D1 D0
Complement accumulator
CMA none The contents of the accumulator are
Example: CMA complemented. No flags are affected.
Complement carry
CMC none The Carry flag is complemented. No
Example: CMC other flags are affected.
Set Carry
STC none The Carry flag is set to 1. No other
Example: STC flags are affected.
CONTROL INSTRUCTIONS
No operation
NOP none No operation is performed. The
instruction is fetched and
Example: NOP decoded. However no operation is
executed.
Halt and enter wait state
HLT none The CPU finishes executing the
current instruction and halts
Example: HLT any further execution. An interrupt or
reset is necessary to
exit from the halt state.
Disable interrupts
DI none The interrupt enable flip-flop is reset
and all the interrupts
Example: DI except the TRAP are disabled. No
flags are affected.
Enable interrupts
EI none The interrupt enable flip-flop is set
and all interrupts are
enabled. No flags are affected. After a
Example: EI system reset or the
acknowledgement of an interrupt, the
interrupt enable flipflop
is reset, thus disabling the interrupts.
This instruction is
necessary to reenable the interrupts
(except TRAP).
Read interrupt mask
RIM none This is a multipurpose instruction
used to read the status of
interrupts 7.5, 6.5, 5.5 and read serial
Example : RIM data input bit. The
instruction loads eight bits in the
accumulator with the
following interpretations.
Set interrupt mask
SIM none This is a multipurpose instruction and
used to implement the
Example: SIM 8085 interrupts 7.5, 6.5, 5.5, and
serial data output. The
instruction interprets the accumulator
contents as follows.