02 MPMC Unit 2 and 3
02 MPMC Unit 2 and 3
Ex.
JMP 2085H - Transfer the program sequence to the memory location 2085H.
LXI rp, data16 - rp is one of the pairs of registers BC, DE, HL used as 16-bit register.
Addressing modes of 8085 Microprocessor
The method by which the address of source of data or the address of destination of result is given
in the instruction is called addressing modes.
The term addressing mode refers to the way in which the operand of the instruction is specified.
Types of Addressing Modes
1. Direct Addressing Mode
2. Register Addressing Mode
3. Register Indirect Addressing Mode
4. Immediate Addressing Mode
5. Implicit Addressing Mode
Direct Addressing Mode
In this mode, the address of the operand is given in the instruction itself.
LDA 2500 H Load the contents of memory location 2500 H in accumulator
LDA is the operation.
2500 H is the address of source.
Accumulator is the destination.
Register Addressing Mode
In this mode, the operand is in general purpose register.
MOV A, B Move the contents of register B to A
MOV is the operation.
B is the source of data.
A is the destination.
Register Indirect Addressing Mode
In this mode, the address of operand is specified by a register pair.
MOV A, M Move data from memory location specified by H-L pair to accumulator.
MOV is the operation.
M is the memory location specified by H-L register pair.
A is the destination.
Immediate Addressing Mode
In this mode, the operand is specified within the instruction itself.
MVI A, 05 H Move 05 H in accumulator.
MVI is the operation.
Low-level/High-level languages
• Machine language and Assembly language are both
– Microprocessor specific (Machine dependent) are called low-level languages
• Machine independent languages are called High-level languages
– For e.g. BASIC, PASCAL,C++,C,JAVA, etc.
i. JMP addr (label). (Unconditional jump: jump to the instruction specified by the
address). [PC] Label.
ii. Conditional Jump addr (label): After the execution of the conditional jump instruction
the program jumps to the instruction specified by the address (label) if the specified
condition is fulfilled.
iii. Specified condition is not fulfilled. If the condition is true and program jumps to the
specified
a. JZ addr (label). (Jump if the result is zero)
b. JNZ addr (label) (Jump if the result is not zero)
c. JC addr (label). (Jump if there is a carry)
d. JNC addr (label). (Jump if there is no carry)
e. JP addr (label). (Jump if the result is plus)
f. JM addr (label). (Jump if the result is minus)
g. JPE addr (label) (Jump if even parity)
h. JPO addr (label) (Jump if odd parity)
iv. CALL addr (label) (Unconditional CALL: call the subroutine identified by the operand)
CALL instruction is used to call a subroutine.
Before the control is transferred to the subroutine, the address of the next
instruction of the main program is saved in the stack.
The content of the stack pointer is decremented by two to indicate the new stack
top.
Then the program jumps to subroutine starting at address specified by the label.
v. RET (Return from subroutine)
vi. RST n (Restart) Restart is a one-word CALL instruction.
The content of the program counter is saved in the stack.
The program jumps to the instruction starting at restart location.
I/O and Machine Control Group:
Instructions for input/output ports stack and machine control.
Examples are: IN, OUT, PUSH, POP, and HLT etc.
i. IN port-address. (Input to accumulator from I/O port) [A] [Port]
ii. OUT port-address (Output from accumulator to I/O port) [Port] [A]
iii. PUSH rp (Push the content of register pair to stack)
iv. PUSH PSW (PUSH Processor Status Word)
v. POP rp (Pop the content of register pair, which was saved, from the stack)
Delays
Delay = No. of T - States / Frequency
For example a “MVI” instruction uses 7 T - States.
If the Microprocessor is running at 2 MHz, the instruction would require 3.5 μSeconds to complete
Delay loops
Loops can be used to produce a certain amount of time delay in a program
Example of a delay loop:
The first instruction initializes 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 C becomes 0
. Tdelay = TO + TL
Nested Loops
Nested loops can be easily setup in Assembly language by using two registers for the two loop counters
and updating the right register in the right loop.
POP D
POP H
POP PSW
POP D (1 Byte Instruction)
– Copy the contents of the memory location pointed to by the SP to register E
– Increment SP
– Copy the contents of the memory location pointed to by the SP to register D
– Increment SP
Increment SP
SPHL
Copy H-L pair to the Stack Pointer (SP)
Loads the contents of the H and L registers into the stack pointer register, the contents of the H
register provide the high-order address and the contents of the L register provide the low-order
address.
The contents of the H and L registers are not altered.
XTHL
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).
RET Instruction
RET ( 1 byte instruction)
– Retrieve the return address from the top of the stack
– Load the program counter with the return address.
CALL 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.
RET conditionally
The program sequence is transferred from the subroutine to the calling program based on the
specified flag of the PSW.
8085 PROGRAMS
Study of Architecture and programming of ICs: 8255 PPI, 8259 PIC, 8251
USART, 8279 Key board display controller and 8253 Timer/ Counter – Interfacing
with 8085 - A/D and D/A converter interfacing.
The 8255A is a general purpose programmable I/O device designed to transfer the data from I/O
to interrupt I/O under certain conditions as required. It can be used with almost any microprocessor.
It consists of three 8-bit bidirectional I/O ports (24I/O lines) which can be configured as per the
requirement.
Features
Widely used programmable parallel I/O device.
40 pin IC
When low the MPU (microprocessor) writes into a selected I/O port or the control register.
RESET:-
active high signal,
A logic high on this line clears the control word register and set all ports in the input mode.
CS [CHIP SELECT] :-
If low it enables the 8255 to respond to RD and WR signals.
A1 – A0 :-
Address lines driven by the microprocessor.
These address lines are used for selecting any one of the three ports or a control word.
CS A1 A0 Selected
0 0 0 Port A
0 0 1 Port B
0 1 0 Port C
0 1 1 Control Word Register
1 X x 8255 is not selected
Ports of 8255A
8255A has three ports, i.e., PORT A, PORT B, and PORT C.
Port A contains one 8-bit output latch/buffer and one 8-bit input buffer.
Port C can be split into two parts, i.e. PORT C lower (PC0-PC3) and PORT C upper (PC7-PC4)
by the control word.
These three ports are further divided into two groups, i.e. Group A includes PORT A and upper PORT
C. Group B includes PORT B and lower PORT C. These two groups can be programmed in three
different modes, i.e. the first mode is named as mode 0, the second mode is named as Mode 1 and the
third mode is named as Mode 2.
As it is I/O mode, D7 = 1.
For example, if port B and upper port C have to be initialized as input ports and lower port C and port A
as output ports (all in mode 0):
In this mode, the ports can be used for simple I/O operations without handshaking signals. Port A,
port B provide simple I/O operation. The two halves of port C can be either used together as an additional
8-bit port, or they can be used as individual 4-bit ports. Since the two halves of port C are independent,
they may be used such that one-half is initialized as an input port while the other half is initialized as an
output port.
'Latched' means the bits are put into a storage register (array of flip-flops) which holds its output constant
even if the inputs change after being latched.
The 8255's outputs are latched to hold the last data written to them. This is required because the data only
stays on the bus for one cycle. So, without latching, the outputs would become invalid as soon as the
write cycle finishes.
The inputs are not latched because the CPU only has to read their current values, then store the data in a
CPU register or memory if it needs to be referenced at a later time. If an input changes while the port is
being read then the result may be indeterminate.
In the input mode, the 8255 gets data from the external peripheral ports and the CPU reads the
received data via its data bus.
The CPU first selects the 8255 chip by making CS low. Then it selects the desired port using
A0 and A1 lines.
The CPU then issues an RD signal to read the data from the external peripheral device via the
system data bus.
In the output mode, the CPU sends data to 8255 via system data bus and then the external
peripheral ports receive this data via 8255 port.
CPU first selects the 8255 chip by making CS low. It then selects the desired port using A0 and
A1 lines.
CPU then issues a WR signal to write data to the selected port via the system data bus. This data
is then received by the external peripheral device connected to the selected port.
When we wish to use port A or port B for handshake (strobed) input or output operation, we initialise that
port in mode 1 (port A and port B can be initilalised to operate in different modes, i.e., for e.g., port A can
operate in mode 0 and port B in mode 1). Some of the pins of port C function as handshake lines.
For port B in this mode (irrespective of whether is acting as an input port or output port), PC0, PC1 and
PC2 pins function as handshake lines.
If port A is initialised as mode 1 input port, then, PC3, PC4 and PC5 function as handshake signals. Pins
PC6 and PC7 are available for use as input/output lines.
1. Two ports i.e. port A and B can be used as 8-bit i/o ports.
2. Each port uses three lines of port c as handshake signal and remaining two signals can be used as
i/o ports.
3. Interrupt logic is supported.
4. Input and Output data are latched.
1. IBF (Input Buffer Full) - It is an output indicating that the input latch contains information.
2. STB (Strobed Input) - The strobe input loads data into the port latch, which holds the
information until it is input to the microprocessor via the IN instruction.
3. INTR (Interrupt request) - It is an output that requests an interrupt. The INTR pin becomes a
logic 1 when the STB input returns to a logic 1, and is cleared when the data are input from the
port by the microprocessor.
4. INTE (Interrupt enable) - It is neither an input nor an output; it is an internal bit programmed
via the port PC4(port A) or PC2(port B) bit position.
1. OBF (Output Buffer Full) - It is an output that goes low whenever data are output(OUT) to the
port A or port B latch. This signal is set to a logic 1 whenever the ACK pulse returns from the
external device.
2. ACK (Acknowledge)-It causes the OBF pin to return to a logic 1 level. The ACK signal is a
response from an external device, indicating that it has received the data from the 82C55A port.
3. INTR (Interrupt request) - It is a signal that often interrupts the microprocessor when the
external device receives the data via the signal. this pin is qualified by the internal INTE(interrupt
enable) bit.
4. INTE (Interrupt enable) - It is neither an input nor an output; it is an internal bit programmed to
enable or disable the INTR pin. The INTE A bit is programmed using the PC6 bit and INTE B is
programmed using the PC2 bit.
Only port A can be initialized in this mode. Port A can be used for bidirectional handshake data transfer.
This means that data can be input or output on the same eight lines (PA0 - PA7). Pins PC3 - PC7 are used
as handshake lines for port A. The remaining pins of port C (PC0 - PC2) can be used as input/output lines
if group B is initialized in mode 0 or as handshaking for port B if group B is initialized in mode 1. In this
mode, the 8255 may be used to extend the system bus to a slave microprocessor or to transfer data bytes
to and from a floppy disk controller. Acknowledgement and handshaking signals are provided to maintain
proper data flow and synchronisation between the data transmitter and receiver.
MODES OF OPERATION OF 8255
All the functions of 8255 A is classified according to two modes: the
Bit Set/Reset (BSR) mode
I/O mode.
BSR mode
Concerned only with the 8 bit of port C
Port C can be set or reset by writing an appropriate control word in the control register.
A control word with bit D7=0 is recognized as a BSR control word.
It does not alter any previously transmitted control word with bit d7=1 : thus the I/O operations of
ports A & B are not affected by the BSR control word.
In the BSR mode individual bits of port C can be used for applications such as an on/off switch.
Control Word format in BSR mode
Bit select: (Taking Don't care's as 0)
I/O MODE
Ports will be function as programmable I/O ports.
Classified into three
Mode 0: Simple Input or Output
Mode 1: Input or Output with handshake
Mode 2: Bidirectional Data Transfer
Mode 0: Simple Input or Output
Basic I/O mode.
ports A and B are used as two simple 8-bit I/O ports and port C as two 4-bit ports.
Each port (or half-port in case of C) can be programmed to function as simply an input or an
output port.
The input/output features in Mode 0 as follows:
1. Output is latched.
2. Inputs are not latched.
3. Ports do not have handshake or interrupt capability.
4. Any port can be used as input or output port.
5. 4-bit can combined used as a third 8-bit port.
The signals when port A & B are configured as output ports as follows:
CASCADE BUFFER/COMPARATOR
– Expands the number of interrupt levels by cascading two or more 8259
INTERRUPT OPERATION
(Sequence of Events)
• The IRR stores the requests
• The priority resolver checks 3 registers:
– IRR for interrupt requests
– IMR for masking bits
– ISR for serving the interrupt request
• It resolves the priority & sets the INT high when appropriate
o MPU acknowledges the interrupt by sending INTA
o Program sequence is transferred to the memory location specified by CALL instruction
• Command word ICW2 is 20H, which specifies the high order byte of the Call address
• The port address of ICW2 is 81H;A0 should be at logic 1
8253 programmable Timer / counter IC
is functionally similar to software designed counters and timers
Modes of Operation
MODE 0: Interrupt on Terminal Count
MODE 1: Hardware – Retriggerable One-Shot
MODE 2 : Rate Generator
MODE 3: Square-Wave Generator
MODE 4: Software Triggered Strobe
MODE 5: Hardware Triggered Strobe
Pin Description
D 0 to D 7 (l/O terminal)
Bidirectional data bus which receives control words and transmits data from the CPU and sends
status words and received data to CPU.
RESET (Input terminal)
A "High" on this input forces the 8251 into "reset status." The device waits for the writing of "mode
instruction." The min. reset width is six clock inputs during the operating status of CLK.
CLK (Input terminal)
CLK signal is used to generate internal device timing.
CLK signal is independent of RXC or TXC.
However, the frequency of CLK must be greater than 30 times the RXC and TXC at Synchronous mode
and Asynchronous "x1" mode, and must be greater than 5 times at Asynchronous "x16" and "x64" mode.
WR (Input terminal)
This is the "active low" input terminal which receives a signal for writing transmit data and control words
from the CPU into the 8251.
RD (Input terminal)
This is the "active low" input terminal which receives a signal for reading receive data and status words
from the 8251.
C/D (Input terminal)
This is an input terminal which receives a signal for selecting data or command words and status
words when the 8251 is accessed by the CPU.
If C/D = low, data will be accessed.
If C/D = high, command word or status word will be accessed.
CS (Input terminal)
This is the "active low" input terminal which selects the 8251 at low level when the CPU
accesses.
TXD (output terminal)
Output terminal for transmitting data from which serial-converted data is sent out.
TXRDY (output terminal)
This is an output terminal which indicates that the 8251is ready to accept a transmitted data
character.
TXEMPTY (Output terminal)
This is an output terminal which indicates that the 8251 has transmitted all the characters and had
no data character.
2) Command
Command is used for setting the operation of the 8251.
It is possible to write a command whenever necessary after writing a mode instruction and sync
characters.
Status Word
It is possible to see the internal status of the 8251 by reading a status word.
Display section
Eight output lines divided into two groups A0-A3 and B0-B3.
The output lines can be used either as a single group of eight lines or as two groups of four lines, in
conjunction with the scan lines for a multiplexed display.
Output lines are connected to the anodes through driver transistor in case of common cathode 7-
segment LEDs.
The cathodes are connected to scan lines through driver transistors.
The display can be blanked by BD (low) line.
The display section consists of 16 x 8 display RAM. The CPU can read from or write into any
location of the display RAM
Scan section
scan counter and four scan lines, SL0 to SL3
Decoded scan mode,
Output of scan lines will be similar to a 2-to-4 decoder.
Encoded scan mode,
Output of scan lines will be binary count, and so an external decoder should be used to convert the
binary count to decoded output.
The scan lines are common for keyboard and display.
The scan lines are used to form the rows of a matrix keyboard and also connected to digit drivers of a
multiplexed display, to turn ON/OFF.
CPU interface section
Takes care of data transfer between 8279 and the processor.
Eight bidirectional data lines DB0 to DB7 for data transfer between 8279 and CPU.
two internal address A =0 for selecting data buffer and A = 1 for selecting control register of8279.
The control signals WR (low), RD (low), CS (low) and A0 are used for read/write to 8279.
It has an interrupt request line IRQ, for interrupt driven data transfer with processor.
The 8279 require an internal clock frequency of 100 kHz. This can be obtained by dividing the input
clock by an internal prescaler.
The RESET signal sets the 8279 in 16-character display with two -key lockout keyboard modes
0 0 0 D D K K K
8- or 16-digit display
Whether new data are entered to the rightmost or leftmost display position.
DD Function
00 8-digit display with left entry
01 16-digit display with left entry
10 8-digit display with right entry
11 16-digit display with right entry
Keyboard Interface of 8279
KKK Function
000 Encoded keyboard with 2-key lockout
001 Decoded keyboard with 2-key lockout
010 Encoded keyboard with N-key rollover
011 Decoded keyboard with N-key rollover
100 Encoded sensor matrix
101 Decoded sensor matrix
110 Strobed keyboard, encoded display scan
111 Strobed keyboard, decoded display scan
Encoded: Sl outputs are active-high, follow binary bit pattern 0-7 or 0-15.
Decoded: SL outputs are active-low (only one low at any time).
Pattern output: 1110, 1101, 1011, 0111.
Strobed: An active high pulse on the CN/ST input pin strobes data from the RL pins into an
internal FIFO for reading by micro later.
The ADC0808 is also same as ADC0809 except the error. The total unadjusted error in ADC0808 is ±
1/2 LSD.
The successive approximation register (SAR) performs eight iterations to determine the digital
code for input value.
The SAR is reset on the positive edge of START pulse and start the conversion process on the
falling edge of START pulse.
This makes the ADC extremely insensitive to temperature, long term drift and input offset errors.
In ADC conversion process the input analog value is quantized and each quantized analog value
will have a unique binary equivalent.
The quantization step in ADC0809/ADC0808 is given by
The DAC0800 is an 8-bit, high speed, current output DAC with a typical settling time
(conversion time) of 100 ns.
It produces complementary current output, which can be converted to voltage by using simple
resistor load.
The DAC0800 require a positive and a negative supply voltage in the range of ± 5V to ±18V.
It can be directly interfaced with TTL, CMOS, PMOS and other logic families.
For TTL input, the threshold pin should be tied to ground (VLC = 0V).
The reference voltage and the digital input will decide the analog output current, which can be
converted to a voltage by simply connecting a resistor to output terminal or by using an op-amp I
to V converter.
The DAC0800 is available as a 16-pin IC in DIP.
ADC Conversion Table
UNIT – I
1. What is microprocessor?
A microprocessor is a multipurpose, programmable logic device that reads binary instructions from a
storage device called memory accepts binary data as input and processes data according to those
instructions and provide result as output.
It is a status signal. It is used to differentiate between memory locations and I/O operations.
When this signal is low (IO/M = 0) it denotes the memory related operations.
SID (Serial input data line): It is an input line through which the microprocessor accepts serial data.
SOD (Serial output data line): It is an output line through which the microprocessor sends output serial
data.
They are sign flag, zero flag, auxiliary carry flag, parity flag and carry flag.
5. List the four instructions which control the interrupt structure of the 8085 microprocessor.
DI ( Disable Interrupts )
EI ( Enable Interrupts )
The ALE (Address latch enable) is a signal used to demultiplex the address and data lines using an
external latch. It is used to enable the external latch.
Instruction cycle- defined as the time required to complete the execution of an instruction.
Machine cycle - defined as the time required to complete one operation of accessing memory, I/O or
acknowledging an external request.
T-cycles - defined as one subdivision of the operation performed in one clock period.
1. Address bus
2. Data bus
3. Control and status signals
4. Power supply and frequency signals
5. Externally initiated signals
6. Serial I/O ports
12. How many machine cycles does 8085 have, mention them
1.
2. Software
Hardware interrupts- The interrupts where the CPU pins are used to receive interrupt requests , are
called hardware interrupts.
Software interrupts – This interrupt is caused by the execution of the instruction. These are special
instructions supported by the microprocessor.
Vectored interrupt - When an interrupt is accepted, if the processor control branches to a specific
address defined by the manufacturer then the interrupt is called vectored interrupt.
Non-vectored interrupt there is no specific address for storing the interrupt service routine. Hence the
interrupted device should give the address of the interrupt service routine.
Software interrupts : RST 0,RST 1,RST 2,RST 3,RST 4,RST 5,RST 6,RST 7
UNIT - II
The accumulator is the register associated with the ALU operations and sometimes I/O operations.
It also temporarily stores the result of the operation performed by the ALU.
3. List out the five categories of the 8085 instructions. Give examples of the instructions for
each group.
Stack I/O and Machine control group – PUSH, POP, IN, HLT.
A CALL instruction leaves information on the stack so that the original program execution sequence can
be resumed.
The IN instruction is used to move data from an I/O port into the accumulator.
The OUT instruction is used to move data from the accumulator to an I/O port.
The IN & OUT instructions are used only on microprocessor which use a separate address space for
interfacing.
A rotate instruction is a closed loop instruction. That is, the data moved out at one end is put back in at
the other end.
The shift instruction loses the data that is moved out of the last bit locations.
The op-code field contains the instruction code (mnemonics). The assembler will translate these
mnemonics into binary.
Operand field contain the data, register name (A, B, C etc.) or address of the memory location on which
on which the operation is to be performed.
LDA copies the data byte into accumulator from the memory location specified
STA copies the data byte from the accumulator in the memory location specified by 16-bit address.
DAA changes the contents of the accumulator from binary to 4-bit BCD digits.
11. What is the use of addressing modes , mention the different types
The various formats of specifying the operands are called addressing modes, it is
used to access the operands or data. The different types are as follows
Immediate addressing
Register addressing
Direct addressing
Indirect addressing
Implicit addressing
The stack is a group of memory locations in the R/W memory that is used for the temporary storage of
binary information during the execution of the program.
The XRA A instruction is used to clear the contents of the Accumulator and store the value 00H.
15. Write 8085 assembly language instructions to store the contents of the flag register in memory
location 2000H.
PUSH PSW
POP B
MOV A,C
STA 2000H.
HLT
To execute a program the starting address of the program is loaded in program counter.
The PC sends out an address to fetch a byte of instruction from memory and increments its content
automatically.
ANA R
ANI 8-bit
ANA M
ORA R
ORI 8-bit
ORA M
XRA R
XRI 8-bit
XRA M
UNIT - III
a) I.O Mode
It is a word stored in a register (control register) used to control the operation of a program digital
device.
The control words written to control register specify an I/O function for each I.O port. The bit D7 of the
control word determines either the I/O function of the BSR function.
Port-A : 8-bits4.
Port-A : 8-bits
Port-B : 8-bits
Port-CU : 4-bits
Port-CL : 4-bits
5. What is an USART?
The control words of 8251A are divided into two functional types.
The command instruction controls the actual operations of the selected format like enable
transmit/receive, error reset and modem control.
Keyboard section
Scan section
Display section
Each of the three counters of 8253 can be operated in one of the following six modes of operation.
Mechanical switches are used as keys in most of the keyboards. When a key is
pressed the contact bounce back and forth and settle down only after a small time delay
(about 20ms). Even though a key is actuated once, it will appear to have been actuated
It determines the priorities of the bits set in the Interrupt request register (IRR).The bit corresponding to
the highest priority interrupt input is set in the ISR during INTA input.
The interrupt request register is used to store all the interrupt levels which are requesting the service.
The eight interrupt inputs sets corresponding bits of the Interrupt Request Register upon the service
request.
The interrupt service register stores all the levels that are currently being serviced.
1. Input modes
Strobed input
2. Display modes