Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Microprocessor Complete 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 56

Downloaded from www.jayaram.com.

np
Microprocessor: A microprocessor is a multipurpose, 80286- introduced in 1982, 16 bit µp with memory
programmable, clock-driven, register base electronic device, addressing capacity of 16 MB, consists of 68 pin with 6-12.5
that reads binary instruction from storage device called MHZ clock signal.
memory accept binary data and input and process data
according to those instruction and provide result as output. 80386 – introduce in 1985 , 32 bit µ p with 4 GB memory
Microprocessor application can be classified as: addressing capability. Consists of 132 pins with 22 to 33
Reprogrammable system: MHZ clock signal.
- In this microprocessor is used for computing and data 80486- introduced in 1989, 32 bit µp with 4 GB memory
processing. addressing capacity, consists of 168 pin with 26-100 MHZ
- Capable of handing large data, storage devices such as clock signal.
disks and CD Rom and peripherals devices such as Pentium:- introduced in 1993, 32 bit up with 4 GB of
printers. Eg microcomputer. memory addressing capacity consists of 168 pins with 100
Embedded system: and 150 MHZ.
- In this case microprocessor is a part of final product Pentium pro, Pentium II , and Pentium III, was
and is not available for reprogramming to end uses. developed each with 32 bit word length having 150-1000
- Eg washing machine, traffic light controller, MHZ clock signal.
Automatic testing machine.
Evolution of microprocessor: Calculator verses computer:-
4004- introduced in 1971, first 4 bit up having memory - Calculator are dedicated devices and can perform
addressing capability of 1 KB arithmetic and logical operations only. Also calculator
- Consist of 16 pin with clock signal of 750 HZ had to be operated manually for each and every steps
8008- introduced in 1972, 8 bit µp , 40 pin to be followed to solve a problem.
8080- introduced in 1973 , 8 bit µp. The computer are programmable in the sense that
8085- introduce in 1976, 8 bit µp having addressing all state steps needed to solve a problem are fed into main
capability of 64kb,cosists of 40 pin with 3-6 MHZ clock memory as program. Than the computer works on the
signal. previous fed program.
8086 – introduce in 1978, 16 bit µP having addressing - calculator has very less memory capacity in
capability of 1 MB , consists of 40 pins with 5-10 MHZ comparison to the computer.
clock signal. - A calculator has a very small size in comparison to
8088- introduced in 1980, 8/16 bit µp with memory the computer.
addressing capability of 1 MB, consists of 5-8 MHZ clock
signal.

Downloaded from www.jayaram.com.np 1 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
microcomputer cpu is single integrated circuit called
microprocessor. The block diagram of microcomputer is
shown above. The major parts are central processing unit,
memory, and input output ports. Each of these part are
connected with each other through address bus , data bus ,
Microcomputer:- and control bus.

I/P device Memory: This consists of a mixture of ram and Rom. It may
also have magnetic floppy disk, magnetic hard disk or
I/P Port
Control Control Control
bus Memory
optical disk. It's function are :
bus Processing
Unit
RAM & ROM 1. Store the binary codes for the sequences of
instruction and then write a program from that
O/P
device
sequence of instruction for the computer.
Address
bus 2. Store the binary coded data with which the
Fig. Block diagram of microcomputer computer is going to work.

I/P port: The i/p section allows the computer to take in data
Microprocessor: from the outside world or send data to the outside world. Eg
keyboard, video display terminals, printers, modems, etc.
The physical devices used to interface the computer buses
ALU
Registry
memory
to external systems are called ports. Two ports are available
i/p port example keyboard, mouse. O/p port example
monitor , printer.
Control
unit Central processing unit: The cpu control the operation
of computer. Cpu fetches binary coded instruction from
memory. Decode the instruction into a series of actions and
carries out these actions in a sequence of steps. It also
contains the instruction pointer register which hold the
Microcomputer: A small computer that contains address of the next instruction or data item to be fetched
microprocessor is microcomputer. They range from 4-bit from memory.
words that can address a few thousand bytes of memory to
32 bit words and can address billions of bytes of memory. In
Downloaded from www.jayaram.com.np 2 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
Address bus: The address bus consists of 16,20,24 or 32 Register array: This area of microprocessor consists of
parallel signal lines. On these lines the CPU sends out the various register identified by B,C, D,E, H, L. These register
address of the memory location that is to be written to or are used to temporary store the data during the execution of
form. a program.

Data bus:The data bus consist of 8, 16 or 32 parallel signal Control Unit: This area provides the timing and control
lines and are bidirectional that CPU can reads data in from signal to all the operations in the microcomputer. It contains
memory and send data out to memory on these lines. the flow of data between the microprocessor memory and
……device in a system will have ……out connected to the peripheral.
data bus but only one device at a time has its out enable.
Control bus: The control bus consists of 4-10 parallel signal Stored Program concept: The task of entering and altering
lines. The CPU sends out signal on the control bus to enable the programs for the ENIAC (electronic numerical integrator
the o/p of the address memory device. Control bus signal are and computer) was extremely tedious. The programming
memory read, write, i/p read, o/p write. concept could be faciliated if the program could represented
in a form suitable for storing in memory along side the data.
Microprocessor: Than a computer could get it's instruction by reading them
form the memory and a program could be set or altered by
setting the values of a portion of memory . This approach is
known stored program concept.
Registry
ALU memory
ALU

Main I/O
memory Equipment
Control
unit
CPU

ALU: This area of microprocessor perform various function Fig: Von-Numann Architecture.
on data. The ALU performs arithmetic operation like
addition subtraction and logical operation like And, OR, X- Main memory is used to store both data and instruction ALU
OR. is capable for performing Arithmetic and logical operation
binary data. The program control unit(cpu) interprets the

Downloaded from www.jayaram.com.np 3 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
instruction in memory and causes them to be a execute. The Address
bus
Program mermory Address bus
input/output unit and helps inputting data and getting results.
The memory of Von-Neumann machine consists Data mermory Address bus
of thousand storage location called words of 40 binary
digits(bits). Both data and instruction are stored in it. Control program Data
bus central counter memroy Data
The storage locations of control unit and control Arithmatic related address program
Memory
Memory
unit unit Hardware arithmatic
ALU are called registers. The various registers of this model unit

are MBR, MAR, IR, IBR, PC, AC.


Data
Program mermory Data bus
Memory Buffer Register: It consist of a word to be stored bus

in memory or is used to receives a memory or is used to


Data mermory Data bus
receive a word from memory.
Fig. Block diagram of the Harvard architecture based µP
Memory address Register: It contain the address in
memory of the world to be written from or read into the
Harvard Architecture based computer consist so separate
MBR.
memory spaces for the programs (or instruction) and data.
Each memory space has it's own address and data bus. Thus
IR(Instruction register): Contain the 8 bit upcode
both instruction and data can fetch from memory
(operation code) instruction being executed.
concurrently.
From the figure it is seen that there are two data and
IBR(instruction buffer register): It is used to temporarily
two and address buses for the program and data memory
hold the instruction from a word in memory.
spaces respectively. The program memory data bus and data
memory data are multiplexed to form single data bus where
PC (program counter): It contain address of next
as program memory Address and data memory address are
instruction to be fetched from memory.
multiplexed to form single address bus. Hence there are two
blocks of ram chip. One for program memory and another
Ac (Accumulator) and MQ(multiplier quotient): They
for data memory space.
are employed to temporarily hold operands and results of
Data memory address arithmetic unit
ALU operations.
generates data memory address. The data memory address
bus carries the memory address of data where as program
Harvard Architecture:
memory address bus carries the memory address of the
instruction.
Central arithmetic logic unit consists of the ALU,
multiplier, Accumulator, etc. The program counter is used to
Downloaded from www.jayaram.com.np 4 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
address program memory. Pc always contains the address of Intel 8085 is a 8 bit general purpose microprocessor capable
next instruction to be fetched. Control unit control the of addressing upto 64kB of memory. It is a 40 pin ic
sequence of operations to be executed. The data and control package fabricated on a single LSI using an NMOS
bus are bidirectional where as address bus is unidirectional. technology. It's clock speed is about 3 MHZ and uses a
single 5v DC supply.
Internal Architecture of 8085: The internal structure of 8085 is shown in figure. It
consists of three main section.
1. Register array.
2. Arithmetic and logic unit.
3. Timing and control unit.

Register array: The 8085 has both 8 bit and 16 bit


registers. It has 8 addressable 8 bit registers and three 16
bit registers. These registers can be classified as a..
General purpose register b. Special purpose register.

a. General purpose register: The 8085 has 6 general


purpose registers to store 8 bit data during program
execution. B,C, D ,E, H, L are 8 bit registers and can
be used singly or 16 bit register pairs. BC, DE, HL.
When used in register pairs , the high order byte
resides in the 1st register that is B when BC is as
register pair and low order byte in second( ie c when
BC is used). The register pair Hl besides it's possible
use as to independent registers functions as a data
pointer. It can hold memory addresses that are
referred to in a number of instructions which use
register indirect addressing.
b. Special purpose register:
Accumulator: It is a 8 bit register used in arithmetic
logic load and store operations as well in input output
instructions.

Downloaded from www.jayaram.com.np 5 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
Flag Register: It is 8 bit register in which the bits carry Arithmetic and logic unit: The ALU performs the
significant information in the form of flags. computing function. It includes the accumulator, the
S- Sing Flag temporary register, arithmetic and logic circuits and the flag
Z- zero flag register. The temporary register is used to store hold data
AC- Auxiliary carry flag during an arithmetic/ logic operation. The result is stored in
D- Parity flag the accumulator and the flags are set or cleared according to
CY- Carry flag the result of operation.

Timing and control unit: This unit synchronizes all the


SZ X AC X P X CY microprocessor operations with the clock. The clock is
symmetrical square wave signal that drives the cpu. The
control circuitary and all the operations are driven by the
clock signals.
Temporary register: It is 8 bit register not accessible to the Interrupt: The 8085 has 5 interrupt signal that can be used
programmer while executing the instruction. The 8085 to interrupt a program execution. The various interrupt
places the date into temporary register for a brief period. signals are, INTR, RST 5.5, RST 6.5, RST 7.5, TRAP.

Program counter: The program counter acts as a pointer to Serial I/p port: The 8085 has two signals to implement the
the next instruction to be executed and always contains 16 serial transmission SID and SOD. This two signals are used
bit address of the memory location of the next instruction. to transmitting the data serially.
The program counter is updated by the processor and points
to the next instruction after the processor has fetched the Data and address bus: The 8085 has 8 bit data bus and and
instruction. hence 8 bit of data can be transmitted parallel from an to a
Stack pointer: The stack is an area of read write memory in microprocessor . The 8085 has 16 bit address bus as memory
which temporary information is stored in first in last out address are of 16 bit.
basis. The stack pointer holds the address of last byte written - The 8 bit significant bits of the address are transmitted
on to the stack. by AD bus. The AD bus transmits the data and
address at different moments. At a particular moment
Instruction register and decoder: These are not accessible it transfers either data or address.
to the programmer after fetching an instruction from - The 8 most significant bit of the address are
memory the processor load it in the instruction register. This transmitted by address bus A bus.
instruction is decoded by the decoder and the sequence of - First of all the 16 bit data is transmitted by the
events are established for the execution of instruction. microprocessor MSB on the A bus and 8 LSB on the
Downloaded from www.jayaram.com.np 6 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
AD bus. Thus the effective 16 bit bus is used for 16 - Does the work of carrying the 8 MSB of the address
bit address. Then data is transfer via AD bus. data.
AD0 – AD7:
8085 Microprocessor unit pin details: - [pins 12 – 19 ] I/O
- It carrys both data and address.
- It carries lower address bits as well as it can be used
+ 5V
as data bus as it can be used as data bus.
1 2
- Carries data of 8 bit.
SID
5 x1 x2
Serial I/O SOD 28
Port 4 A15 ALE (Address latch enable):
TRAP
6
A8 21 - Pin 30, output pin
Externally
RST 7.5
7 19 - It goes high during first clock cycle of a machine
initiated RST 6.5 AD7
signal 8 cycle.
RST 5.5
INTR
9 AD0
12 - When high, AD0 – AD7 is used as address bus.

30 ALE
READY IO/ M :
29 S0
HOLD
39 33 S1 Control and - pin 34, o/p pin
RESET Status signal
36 34 IO/M - Distinguishes whether the address is fir memory or
INTA
External
signal
11 32 RD I/O
HLDA WR
qck 38 3 37 31
- When high the operation is performed between I/O
and µP
- When low the operation is performed between
Reset CLK memory and µp.
OUT OUT
S0 , S1 :
- Pin 29, 33, o/p pin
Intel 8085 contains 40 pins as shown in figure which has
- These are status signals and indicates the type of
- 8 unidirectional address pins (A8 to A15)
operation performed.
- 8 bidirectional multiplexed address/data pins (AD0 to
S0 S1 Operation
AD7)
0 0 HALT
- 11 control output pins
0 1 READ
- 11 control input pins.
1 1 WRITE
- Two power supply pins +5v and ground.
1 1 FETCH (bring info. From the
- A8 – A15 (pin 21 – 28) output
Memory to µP)
Downloaded from www.jayaram.com.np 7 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
INTR:
RD : - pin 10 , input pin
- Pin 32, o/p pin - It is an interrupt request signal.
- Controls READ operation. - When it goes high the program counter does not
- When it goes low, the selected memory or I/O device increment its content. The µP suspects its normal
is read. sequence of instruction at hand it goes to the CALL
WR : instruction.
- Pin 31, o/p pin
- A low indicates a write operation being performed INTA:
into the selected memory or I/P device. - pin 11, o/p
- The µP sends as interrupt ack after INTR is received.
READY:
- Pin 35, i/p pin
- It is used to sense whether a peripheral is ready to RST 5.5, RST 6.5, RST 7.5 & TRAP:
transfer data or not. - Pin 9,8 , 7 & 6, input pin
- If READY is high, the peripheral is ready. - These are interrupt signals.
- It is low, the µp waits till it goes high. - When interrupt is recognized, the next instruction is
executed from a fixed location.
HOLD ( when high): - RST 7.5,6.5,5.5 are ……..interrupt.
- pin 39, i/p pin
- It indicates the another device is requesting the use of
buses. Having received a HOLD request the µP stops RESET IN :
the use of the buses as soon as the current instruction - pin 36, input pin.
is completed. The processor regains the bus after the - When signal on this pin is low, the µP is reset.
removal of the HOLD singnal.
RESET OUT:
HLDA: - pin 3, output pin.
- Pin 38, 0/p pin. - This signal indicates that µP is being reset.
- A signal for HOLD ack. - This signal can be used to reset other devices.
- It indicates that the HOLD request has been received.
- After the removal of a HOLD request the HLDA goes X1, X2 :
low. - Pin 1, 2 , i/p pin.

Downloaded from www.jayaram.com.np 8 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
- These are terminals to connect to an external crystal Microprocessor instruction:
oscillator which drives on internal circuitary of the µP Register transfer language(RTL): The internal network
to produce a suitable clock for the operation of µP. organization of a digital computer is defined by specifying.
- The set of register it contains and their functions.
CLK: - The sequence of micro operation performed on the
- pin 37, output pin. binary information stored in the registers.
- It is a clock output for user which can be used for - The control that initiates the sequence of micro
other digital ICs operation.
- Its frequency is same at which processor operates. The symbolic notation used to describe the micro
operation transfer among register is called register
SID: transfer language .
- pin 5, input pin.
- It is a data line for serial i/p. Fetch and execute cycle:
- The SID signal can be used to i/p the SID pin to the Eg: Mov
most significant bit of the accumulator. If the next instruction in the pc is Mov A,B then
Fetch cycle:
SOD: T1: MAR- pc
- Pin 4, o/p pin. T2: MBR – M
- It is a data line for serial o/p. T3: IR- (MBR)
- It can be used to o/p the most significant bit of the PC- Pc+1
accumulator. Execute cycle:
T1: MAR-(IR (address of B))
VCC: T2: MBR-(B)
- pin 40, input pin. T3: MAR-(IR( address of A))
- +5v dc supply. T4: A- PC
In fetch cycle the last two operations are included within
Vss : a single time unit T3 as the increment of pc takes place
- Pin 20, input pin. immediately after the content of MBR gets transferred
- Ground. into instruction registers. The representation, T1, T2, T3
- represent time units and are of equal duration operations
performed within this single unit is called micro
operation.

Downloaded from www.jayaram.com.np 9 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
8085 instruction Description: LDA ,2500H , LDAX B
c. Between a memory location and register.
Instruction: It is command given to a computer to Eg. LXI B,2000H
perform specific operation on given data. The entire LXI- load immediate at location.
group of instructions called the instruction set determines d. Between an input/output device and location.
what functions the micro processor can perform. Eg. IN 02H , OUT PORT 1
It has two parts
Opcode : Specifies what operation to be performed. 2 Arithmetic instruction: These instruction perform
Operand: Specifies where to perform the operation. arithmetic operations such as addition, subtraction,
increment, and decrement.
opcode operand i. Addition: Any 8 bit number or the content of
register or the content of memory location can
Instruction of a computer: The computer can be used to be added to the content of accumulator and the
perform a specific task only by specifying the necessary sum is stored in the accumulator. No two other
steps needed to complete the task. The collection of such 8 bit register can be added directly.
ordered steps forms a program of a computer. The Add B,
program is thus collection form of such steps called ADD M
instruction. ADI 06H
ii. Subtraction: Any 8 bit number or the content
Categories of instruction: of register or can be subtracted from the content
1. Data Transfer instruction. of accumulator and result is stored in the
2. Arithmetic instruction. accumulator.
3. Logical instruction. eg Sub B, Sub M, SBI 06H
4. Branch instruction. 3. Increament/Decreament : The 8 bit contents of
5. Machine control instruction. register or memory location can be increased or
decreased by 1.
1. Data transfer instruction: This instruction copies INR B
data from one location called source to another location DCR B
called destination without modifying the content of the INX H
source. The various types of data transfer instruction are : DCX H
a. Between register: eg MOV A, B , MOV C,A 4. Logical instruction: The instruction of this group
b. Specific data byte two a register or memory location. perform logical operation like AND, OR,
Eg. MVI B,32H Compare, rotate etc.
Downloaded from www.jayaram.com.np 10 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
CMP – address of the registers in addition to the operation to
RAL- be performed. MOV A, B , MOV B, ADD B, SUB C
ANA- 4. Register indirect addressing mode: In this mode of
ORA- addressing the address of operand is specify by the
5. Branch instruction: List instruction alters the register pair as a pointer for operand. Eg, LXI H,
sequence of program execution either conditionally or 2500H , MOV A,M , ADD M
unconditionally. 5. Implied addressing mode: There are certain
Jump: These instruction test for certain condition instruction which operate on the content of a
and altered the program sequence when the condition is accumulator such instruction do not require the
met. Eg JC, JZ, JNC, JNZ address of operand. Eg, CMA, RLA, RAR, NOP,
Call, return and restart: These instruction change a HLT
sequence of program either by calling a subroutine or
returning from subroutine.
Instruction cycle: The necessary steps that the cpu
6. Machine controlled operation or instruction: This carries out to fetch an instruction and necessary data from
instruction control machine function such as Holt, Not the memory and to execute it constitute and instruction
Stop, End Operation. Eg: HLT, NOP, EI cycle it is defined as the time required to complete the
execution of an instruction.
An instruction cycle consists of fetch cycle and
Addressing modes: Each instruction requires certain execute cycle. In fetch cycle CPU fetches upcode from
data in which it has to operate. There are various the memory . The necessary steps which are carried out
technique to specify data for instructions. These to fetch an upcode from memory constitute a fetch cycle.
technique are called addressing mode. The necessary steps which are carried out to get data if
any from the memory and to perform the specific
1. Direct addressing mode: In this mode of addressing operation specified in an instruction constitute and
the address of the operand(data) is given in the execute cycle . The total time required to execute an
instruction it self. Eg. STA 2400H, IN 02H instruction given by IC = Fc+ Ec
2. Immediate addressing mode: In this addressing The 8085 consists of 1-6 machine cycles or operations.
mode the operand is specified within the instruction
itself . eg. AVI A, 06L , LXI H, 2500H Fetch cycle: The first byte of an instruction is it's upcode
3. Register addressing mode: The operand are in . The program counter keeps the memory address of the
general purpose register. The upcode specifies the next instruction to be executed in the beginning of fetch
cycle the content of the program counter ,which is the
Downloaded from www.jayaram.com.np 11 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
address of the memory location where upcode is
available , is send to the memory. The memory places the
upcode on the data bus so as to transfer it to CPU. The
entire process takes 3 clock cycle.

Execute cycle/Operation:- The upcode fetched from the

Fig. inst. Cycle showing FC, EC, IC


memory goes to IR from the IR it goes to the decoder
which decodes instruction. After the instruction is
decoded execution begins.
- If the operand is in general purpose register ,execution
is performed immediately. I,e in one clock cycle.
- If an instruction is contains data or operand address ,
then CPU has to perform some read operations to get
the desired data.
- In some instruction write operation is performed. In
write cycle data are sent from the CPU to the memory
of an o/p device.
- In some cases execute cycle may involve one or more
read or write cycle or both.

Fig. inst. Cycle showing FC, EC, IC

Downloaded from www.jayaram.com.np 12 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np

Machine cycle: It is defined as the time required to


complete one operation of accessing memory , i/p, o/p or
acknowledging and external request. This cycle may
consists of 3 to 6 T states.
Fig. Fetch cycle

T-states: It is defined as one sub division of the operation


performed in one clock period. These sub division are
internal states synchronized with system clock and each T
states precisely equal to one clock period.

Timing diagram: The necessary steps which are carried in a


machine cycle can represented graphically. Such graphical
representation is called timing diagram.

Timing Diagram:

Fetch execution overlap:

t1 t2 t3

I1 F E1

F2 E2
I2

Downloaded from www.jayaram.com.np 13 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
- The 8085 puts a low in the IO/ M lines of the system
Signal
T1 T2 T3 T4 indicating memory operation.
- The 8085 sets So = 1 and S1= 1 on the system bus
CLK indicating memory fetch operations.
- The 8085 places the pc high byte on the A8 to A15
lines and the PC low bytes on the AD0- AD7 lines of
IO/M the system bus. The 8085 also sets ALE signal to high
as soon as ALE signal goes low the AD0 to AD7 lines
are used as data lines for reading the upcode.
- At the beginning of T2 the 8085 puts the RD lines to
S0, S1 low indicating a read operations. After some time the
8085 loads the upcode into the instruction registers.
A8 - A15 - During T4 clock period the 8085 decodes the
instructions.
Out In

AD0 - AD7 Timing diagram for memory read cycle:

ALE

RD

Downloaded from www.jayaram.com.np 14 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np

I/O read: I/O write:

Signal Signal
T1 T2 T3 T1 T2 T3

CLK CLK

IO/M IO/M

S0 S1

S1 S0

A8 - A15 A8 - A15

Out In Out In

AD0 - AD7 AD0 - AD7

ALE ALE

RD WR

Downloaded from www.jayaram.com.np 15 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np

General Control signal:

IO/ M RD WR Signals generated Assembly language Programming: Among three different


0 0 1 MEMR programming language of the computer , assembly language
0 1 0 MEMW programming represents the programming level in between
1 0 1 IOR the machine language and the high level language. Since
1 1 0 IOW machine language program consists of either binary or
hexadecimal opcodes, programming microprocessor with it
MOV A, B = 1MC – opcode fetch – 4 T state is difficult because one must deal with numbers programs in
MVI A, 32H = 2MC – opcode fetch, 1 memory read – 7 T assembly and high level languages are represented by
states instructions that use English language type statement. Thus
STA 2050H- 4 MC- opcode fetch, 2 memory read , 1 it is more convenient to write programs in assembly
memory write. language then in machine language. However the
MOV A, M- 2 MC- 1 opcode fetch, 1 memroy write. microprocessor can only understands the binary numbers
IN 84H – 3 MC – opcode fetch, 1 memory read, i/o read. and hence a translator is used to convert assembly or high
OUT 02H – 3 MC – opcode fetch, 1 memory read, 1 i/o level program into binary machine language so that
write. microprocessor can execute the program.
JMP 2050 – 3 MC – opcode fetch, 2 memory read. (when
condition satisfied) Linker: A large program is generally divided into smaller
- 2 MC- opcode fetch, 1 memory read. (When condition programs known as modules. It is easier to develop to test
unsatisfied) and debug smaller program.
ADI 12H- 2MC- opcode feth, 1 memory read. A linker is a program which links smaller program
together to form a large program while developing a
program , subroutines which are stored in the library file are
frequently used in the program. The linker links these
subroutines with the main program. It converts object codes
into executable form.

Downloaded from www.jayaram.com.np 16 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
Assembler: It is a program that translates assembly Semicolon- Before comment
language mnemonics or source code into binary code or
object code. This translation requires that the source
program be written strictly according to the specified syntax 1.Write a program to perform the following :
of the assembler. a). Load the no: 1BH in D
b) Load the no. B5H in B
C). Increment the content of B by 1.
Assembly language format: d). Decrement the content of D by 1.
e). Subtract the content of D from the content of B.
Label opcode operand comments f). Display the result at OUT port 1.

jump MOV A, B MVI D,1BH


MVI B,B5H
A typical assembly language format is divided into four INR B
parts called fields. They are level, opcode, operand and DCR D
comments. MOV A, B
SUB D
- The assembler statements have free field format OUT PORT 1
which means that no of blanks can be left between the HLT
fields.
- Comments are optional but help for good 2 Wap to load the data byte in the register C. Mask the
documentation. high- order bits (D7-D4) and display the low order bits
- A level for and instruction is also optional but it's use (D3-D0) at outport. Exclusive-OR the result with 57H
greatly facilitates specifying the jump location. and display at OUT PORT2.
eg. Label opcode operand comments Solution: MVI C, A8H
Start: LXI sp, 20FFH ; initialize MOV A, C
the stack pointer. ANI OFH
OUT PORT1
These fields are separated by delimeters . Typical delimeters XRI 57H
use are OUT PORT 2
Space- between each field HLT
Comma- between two operand 3. Wap to load the byte 8EH in register D and F7H in
Colon- After label register E. Mask the higher order bits (D7 – D4) from
Downloaded from www.jayaram.com.np 17 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
both the data bytes , EX-OR the low order bit (D3-D0) d) If two nos . are equal , display 01 otherwise display
and display the answer. 00H at port 1.
Solution: MVI D, 8EH Solution: MVI A, byte 1
MOI A, D MVI B, byte 2
ANI SUB B
MVI D, 8EH JNZ loop
MVI E, F7H MVI A, 01H
MOV A, D OUT PORT 1
ANI OFH HLT
MOV D, A Loop MVI A, 00H
MOV A, E OUT PORT
ANI OFH HLT
XRA D 6. The following block of data is stored in memory location
OUT PORT 1 from CO55 to C05A H. Transfer the entire block of data
HLT to the locations C080 to C085 H in reverse order.
4. Write a program to load two unsigned nos in register B Data: 22, A5, B2, 99, 7F, 37
and C respectively . Subtract c from B. If the result in 2's Solution: LXI H, C055 H
complement convert the result in absolute magnitude and LXI D, C085 H
display it port 1. Otherwise display the result. MOV B, 06H
Solution: MVI B, byte 1 Next MVI A, M
MVI C, byte 2 STAX D
MOV A, B INX H
SUB C DCX D
JNC label 1 DCR B
CMA JNZ next
ADI 01H HLT.
Label 1 OUT PORT 1 7. Write a program to find larger of two nos. 1st no in C001
HLT and 2nd no in C002 and result in C003 H.
5. Write an ALP to do the following: Solution: LXI H, C001 H
a) Load A with byte 1. MOV A, M
b) Load B with byte 2. INX H
c) Compare the equality of the contents of A and B CMP M
JNC loop
Downloaded from www.jayaram.com.np 18 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
MOV A, M JNZ loop2
Loop STA C003 H DCR B
HLT JNZ loop 1
8. Write an ALP to find the smallest no in a data array. Data OUT PORT 1
from location C000H to C005 H. HLT
Solution: LXI H, C000H 11. Write an ALP to count the no of 1 in the given string
MVI C, 06H '10100110' and display the result at COCOH
MOV A, M Solution: MVI A, A6 H
DCR C MVI B, 00H
Loop INX H MVI C, 08H
CMP M Loop1 RAL
JC loop1 JNC loop2
MOV A, M INR B
Loop1 DCR C Loop2 DCR C
JNZ loop JNZ loop 1
STA C0C0 H MOV A, B
HLT. STA COCOH
9. Write an ALP to multiply two nos: eg 05 H × 08 H HLT
Solution: MVI A, 00H 12. The following datas are stored in memory location
MVI B, 08H starting from C0B0 to C0B9 H . Take a test no. 48. Find
MVI C, 05H out how many times the no 48 is repeated. Display the
Loop ADD B result at C0C0H .
DCR C DADA: 12, 23, 34, 45, 48, 56, 48, 67, 48, 89.
JNZ loop Solution: LXI H, C0B0 H
STA C000H MVI B, 00H
HLT MVI C, 0A H
10. Write an ALP for the following addition. Loop 1 MOV A, M
12+22+32+42+52+62+72+82+92 CPI 48 H
Solution: MVI A, 00H JNZ loop2
MVI B, 09H INR B
Loop 1 MOV C, B Loop 2 INX H
Loop 2 ADD B DCR C
DCR C JNZ loop1
Downloaded from www.jayaram.com.np 19 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
MOV A,B JNZ Loop 1
STA COCO H Loop2 STA COC1 H
HLT MOV A, C
13. 8 bit multiplication , product is 16 bit . The multiplicand STA COCO H
is loaded in the two consecutive memory locations 2501 HLT
and 2502 H . The multiplier is stored in 2053 H. Store the 15. To arrange 54 , EB, 85, A8 & 99 in descending order.
product in 2504 and 2505 H. These numbers are stored in the memory location 2501 to
Solution: LHLD 2501 H 2505 H. The count = 05 is restored in 2500 H. Results
XCHG are to be stored in 2601 to 2605 H.
LDA 2503 H Solution:
LXI H, 0000 LXI D, 2601 H
MVI C, 08 LXI H, 2500 H
Loop1 DAD H MOV B, M
RAL Start CALL Subroutine 1
JNC loop2 STAX D
DAD D CALL Subroutine 2
Loop 2 DCR C INX D
JNZ loop1 DCR B
SHLD 2504 H JNZ start
HLT HLT
14. Write an ALP to divide two nos. The dividend is in C001 Subroutine 1:
and divisor is in C002. Store the quotient in C0C0 H and LXI H, 2500 H
remainder in C0C1. SUB A
Loop1: INX H
Solution: LXI H, C001 H CMP M
MOV A,M JNC loop 2
INX H MOV A, M
MOV B,M Loop2: DCR C
MVI C, 00H JNZ Loop 1
Loop1 CMP B RET
JC Loop2 Subroutin2:
INR C LXI H, 2500H
SUB B MOV C, M
Downloaded from www.jayaram.com.np 20 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
Loop1 INX H TD = T0 + TL
CMP M = 3.5 + 1785
JZ Loop2 = 1788.5
DCR C = 1.7885 ms
JNZ Loop1
Loop2 MVI A, 00H Time delay for register pair:
MOV M, A LXI B, 2384 H ………………. 10 T state
RET Loop DCX B …………………. 6 Tstate
Note: Subroutine 1 gives the largest number of array. MOV A, C …………………….. 4 T state
Subroutine 2 find the largest number and replace it by 00. ORA B ………………………… 4 T state
JNZ loop ………………………. 10/7

Counter and delay: Delay calculation:

Timing delay using one register: T0 = T state * T


= 10 × 0.5 × 10-3
MVI C, FFH ---------- 7 T state = 109 ms
Loop DCR C -------------- 4 T state TL = No of T state * T * (N10)
JNZ Loop -------- 10 or 7 T state = 24 * 0.5 * 90.92
Consider a micro computer with 2 MHZ frequency
Clock period , T = 1/f = ½ = 0.5 µ sec Total Delay = T0 + TL
Delay for inst. Outside the loop To = No of Ts state × T =
= 7 × 0.5
= 3.5 µ sec Time delay using a loop within a loop:

MVI B, 38 H …….. 7 T
Delay for inst inside the loop, TL = No of T state × T * (N10) Loop2 MVI C, FFH ………7 T
= ( 14× 0.5 × 10-6 ×255) Loop 1 DCR C……..4 T
= 1785 µ sec JNZ loop1 ------10/7 T
Now TLA = TL-3× 0.5 DCR B ------ 4 T
= 1785 – 1.5 JNZ loop2 ------ 10/7 T
= 1.7835 ms
Delay calculation:
Downloaded from www.jayaram.com.np 21 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
Count = 140.35
= 8C H
To = 7 * 0.5 = 3.5 µ sec
Q. Write a program to generate a continuous square wave
TL1 = 14 * 0.5 * 255 – 3*0.5
with the period 500 µ sec. Assume the system clock period
TL2 = ( TL1 + 21*0.5) N10 – 3 is 325 µ sec and use bit Do to output the square wave.

Total dealy = To + TL2 Solution:


MVI D, AA
Q. Write a program to count continuously in hexadecimal ROTATE MOV A, D
from FFH to 00H in a system with a 0.5 µ s clock period. RLC
Use register C to set up a 1 ms delay between each count MOV D, A
and display the number at one of the o/p ports. ANI 01 H
OUT PORT 1
MVI B, 00H
MVI B, count
Next DCR B
Delay DCR B
MVI C, count
JNZ delay
Delay DCR C
JMP ROTATE
JNZ delay
MOV A, B
Delay calculation:
OUT port 1
TL = 14 * 325 * 10-9 * count or 14 * 325 * (count - 1) +
JMP Next
11 T-state * 325
T0 = 46 * 325 * 10-9
Delay calculation:
TD = TL + T0
250 = (52.4)10 = 34 H
TL = T state * T* (T10)
= 14 × 0.5 × count
Types of Assemblers:
= 7 × count µ s
To = 35 × T
1. One pass assembler
= 35 × 0.5
2. Two pass assembler
= 17.5 µ s
One pass assembler:
TD = TL + To
1 ms = 7 * count * 10-6 + 17.5 * 10-6
Downloaded from www.jayaram.com.np 22 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
This assembler goes through the assembly language
programs one and translate the assembly language program Pass 1:
into machine language program . Address Machine Label Opcode Operand Symbol
This assembler has the problem of defining forward code table
references this means that a jump instruction using an 2000 start IN PORT 0 PORT 0
address that appears latter in the program must be defined by 2002 OUT PORT 1 00H
the program after the program is assembled 2004 JMP start PORT 1
01H
Two pass assembler: Start
This assembler scan the assembly language twice. In 2000H
st
the 1 pass, the first memory location is determined from the
‘ORG’ statement and the counter knows the location i,e Pass 2:
counter is initialized . Then the assembler scans each 2000 D3 00
instruction and records location in the address column. The 2002 D3 01
address location counter keeps tracks of the byte in the 2004 C3 00,20
program. The assembler also generates a symbol table in the
1st pass. When it comes across the label , it records the label
and location. The assembler Directives:
In the second pass each instruction is examined Assembler directive are the instruction to the
and menominocs and label are replaced by the machine assembler concerning the program being assemble l they are
code. also called pseudo instruction or pseudo upcode. They
e.g PORT 0 EQU 00H define the way according to which micro computer is
PORT 1 EQU 01H directed to perform a specific task. These instruction are
ORG 2000H neither translated into machine code nor assigned any
Start, IN PORT 0 memory location in the object file. Few assembler directive
OUT PORT 1 are explained below.
JMP start
END ORG (Origin): The pseudo instruction lets the programmer
place the program anywhere in the memory. Internally the
When this program is assembled by one pass assembled the assembler maintains a program counter type registor called
program is converted into it’s machine code in the 1st pass address counter . This counter maintains the address of the
only. next instruction or the data to be processed e.g
In case of two pass assembler the task is shown as below. ORG 7000 H
Downloaded from www.jayaram.com.np 23 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
MVI A, 02 This will assign C2 to location 700H and 4A to 700H and
4A to 7001 H location. It is assumed that assembler will
The 8085 assembler will generate the following code for this assign low byte first (C2) and high byte (4A).
statement
7000 3E END: This pseudo instruction is used to define the end of
7001 02 assembly. The HLT instruction suggest the end of a program
but that does not mean that it is the end of the assembly.
EQU ( equate): This pseudo instruction assigns a value in
it’s operand field to an address in it’s label field. This allows Bus structure and memory devices:
the user to assign numeric value to a symbolic name. The
user can then use the symbolic value in the program instead 1. Data bus
of it’s numeric value. 2. Address bus
START EQU 0200H 3. Control bus.
This assign the value 0200H to the label start.
Data bus: Data bus provides a path for monitoring data
2000------Jump between the system modules. The data bus consist of
2001------00 number of separate line 8, 16, 32, or 64. The number of lines
2002------02 is referred as a width of data bus. Since each line can carry
only one bit at a time. The number of lines determine how
PORT A EQU 40H: Here PORT A is assign value 40 H. many bits can be transmitted at a time. the width of the bus
is key factor in determining the overall system performance.
DB ( Define byte):
This pseudo instruction is used to initialized a area Address bus: The address bus are used designate the source
byte by byte. Assembled bytes of data are stored in or destination of the data on data bus . Examples: if the CPU
successive memory location until all values are stored. requires to read a word (8, 16 or 32) bits of data from
e.g ORG 2000H memory, it puts the address of the desire word on the
Data: DB 20H, 30H, 40H, 50H address bus. The width of the address bus determines the
maximum possible memory capacity of the system. The
DW( Define word): This pseudo instruction is used to address bus is also used to address input output ports. The
assign a 16 bit value to two memory location. e.g ORG higher order bits are used to select a particular modules on
7000H, START DW 4AC2 H the bus and the lower order bits select memory location or
⎛ 7000 C 2 ⎞ input / output port within the module.
⎜ ⎟
⎜ 7001 4 A ⎟
⎝ ⎠
Downloaded from www.jayaram.com.np 24 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
Control bus: The control bus is a group of lines used to
control the access to and the use of data and address bus Clock

since data and address buses are shared by all components of


micro processor system control signal transmit command
and timing information between the system module. The Start
timing signal indicate the validity of data and address
information where as command signal specify operation to
be performed. Some of the control signals are : Read

- Memory read.
- Memory write.
Address
- Input/ output write.
- Transfer acknowledgement.
- Bus request. Data bus
- Bus grant.
- Interrupt request.
- Interrupt ack. ACK signal

Synchronous Bus: In synchronous bus the occurance of the The above diagram describes the following steps.
events on the bus is determined by a clock. The clock - The CPU issues a START signal to indicate the
transmits a regular sequences of zeroes and one of equal presence of address of control information on bus.
duration. A single zero-one or 1-0 transmission is called - Then it issues memory read signal and places the
clock cycle and defines a time slot. All other devices on the memory address on the address bus.
bus can read the clock live and all events starts at the - The addressed memory module recognizes the address
beginning of clock cycle. and often a delay of one clock cycle it places the data
signals on the buses.

Asynchronous bus: In an asynchronous bus the timing is


maintained in a such a way that occurrence of one events on
the bus follows and depends on the occurance of the
previous events.

Downloaded from www.jayaram.com.np 25 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np

Read Memory:
A memory unit is a collection of storage cells
Address
together with associated circuits needed to transfer
information in out of storage. The memory stores binary
information in groups of bits called words. A memory is a
Master group of 1’s and 0’s and may represent a number, an
synchronous
(MSYNC) instruction code one or more alphanumeric characters or any
Data bus
other binary-coded information. A group of 8 bits is called a
byte. The capacity of memories in commercial computers is
usually stated as the total number of bytes that can be stored.
For 8 bit micro-computer system memory word and
memory byte are the same. A memory word is identified by
- The CPU places the memory read and the address an address. The 8 bit microprocessor uses 16 bit address to
signals on the bus. access memory word. This provides a maximum of 216 =
- After allowing for these two signals to stabilized, it 65536 memory addresses ranging from 0000H to FFFF H.
issues master synchronous signal ( M SYNC) to Thus , the memory capacity for this Micro-computer system
indicate the presence of valid address of control is 64K.
signals on the bus.
- The addressed memory module responds with the data Memory can be classified as non-volatile memory or
and the slave synchronous ( SSYNC). volatile memory. Non-volatile memory retains the stored
data even when there is no power. On the other hand volatile
memory losses its contents when the power is removed. Few
examples are:

Non volatile: ROM, PROM, EPROM, Floppy disk, hard


disk etc.
Volatile: RAM ( static dynamic), CCD ( Charge coupled
devices etc).

In broad sense, a microcomputer’s memory system can be


divided into three groups;
i. Processor memory
Downloaded from www.jayaram.com.np 26 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
ii. Primary memory is a program whose function is to start the computer
iii. Secondary memory. software operating when power is turned on. Since RAM is
volatile, its contents are destroyed when power is turned off.
The contents of ROM remain unaltered after power is turned
Processor Memory: off and on again. The startup of a computer consists of
Processor memory refers to a set of turning the power on and starting the execution of an initial
microprocessor registers. They are used to hold temporary program. Thus when power is turned on, the hardware of the
results when a computation is in progress Although use of computer sets the program counter to the first address of the
such registers enhances the execution speed, the cost bootstrap loader. The bootstrap program loads a portion of
involved in the approach forces a micro-computer designer the operation of the operating system from disk to main
to include only a few registers include the processor. In 8085 memory and control is then transferred to the operating
we have registers like A, B, C, D, E, H, L, SP, PC etc to system, which prepares the computer for general use.
store data temporarily. The principle on which ROM is based can
be explained with the help of figure below. This ROM is
Primary Memory: constructed with diodes.
It is the storage area where all programs
are executed. The microprocessor can directly access only +5v

those items that are stored in the primary memory. Hence,


all programs and data must be within the primary memory 0
prior to execution. Usually, the size of the primary memory R0
1
is much larger than that of processor memory and its R1
operating speed is much slower than processor’s registers. 2
R2
3
Primary memories can be divided into two main groups: R3
1. Read only memory (ROM) 4
R4
2. Random Access memory. (RAM) 5
R5
Read only memory (ROM): 6
R6
7
ROM is a non volatile memory and can be read R7
D3 D2 D1 D0
only. It is used to store data and programs that are not to be
altered. Among other things ROM is needed for storing an
initial program called boot strap loader. The bootstrap loader
Downloaded from www.jayaram.com.np 27 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
Fig. simple diode ROM memory can be programmed by the user with a special
PROM programmer that selectively burns the fuses (
Here, each horizontal row is a register or memory location. applying high current) according to the bit patters to be
The Ro register contains three diodes, the R1 register has one stored. The process is known as ‘burning the PROM’, and
diode, and so on. The output of the ROM is the word. the information stored is permanent.
D = D3D2D1D0
EPROM (Erasable PROM): EPROM uses MOSFETS.
In switch position 0, a high voltage turns on the diodes in R0 Data is stored with PROM programmer. Later data can be
register; all other diodes are off. This means that a high erased with ultraviolet light. The light posses through a
output appears at D2, D1, D0. Therefore the word stored at quarts windows in C package on the chip, where it releases
memory location 0 is stored charges. The effect is to wipe out the stored contents.
D = 0111 In other word, the EPROM is ultraviolet-light-erasable and
When the switch is moved to position 1. The diode in the electrically programmable. Once the chip is programmed the
register R1 conducts; all other diodes are off. Thus the word window is covered with opaque tape to avoid accidental
stored at memory location 1 is erasing.
D = 1000
EEPROM ( Electrically erasable PROM): This is non-
Similarly, datas in other registers are stored with integrated volatile like EPROM but does not require U-V rays to be
circuits manufacturer stores the word at the time of erased. It can be completely erased or have certain byes
fabrication. The words are permanently stored once the changed, using electrical pulses. Writing to EEPROM is
diodes are wired in place. In fabrication ROMs the slower than writing to RAM, so it can not be used in high
manufacturer may use bipolar transistors or MOSFETS. speed circuits.
But the idea is still basically the same, the transistors or
MOSFETs act like the diodes in the figure above. ROMs can FLASH MEMORY: This is a modified EEPROM. The
be classified as below: difference is the erasure procedure. EEPROM can be erased
at a register level, but flash memory must be erased either in
Masked ROM: In this ROM, a bit pattern is permanently its entirety or at the sector (block) level.
stored. Memory manufactures are generally equipped to do
this.
Random Access memory OR Read/Write memory: It is a
PROM ( Programmable ROM): This memory has volatile memory and is used in store programs and datas for
nichrome or polysilicon wires arranged in a matrix . These immediate use of the processor. Data can be readily written
wires can be funcitionally viewed as diode or fuse. This
Downloaded from www.jayaram.com.np 28 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
into and read from a RAM at any selected address in any easily as any other. Most of today’s microprocessor
sequence. Two types of read/write memories are available: memory system are random access. It includes RAM and
- Static RAM ROMs both. Originally RAM, was used to refer to random
- Dynamic RAM access memory but now it is used to designate a read/write
memory.
Static RAM: This memory is made up of flip flops; and Sequential-access memory means a memory in which to
stores the bits as voltage. Each memory cell requires six access a memory location you must access every memory
transistors. This memory is more expensive and power location between the presents memory location you are
consuming than dynamic memory. It is called ‘static’ addressing and the memory location that you want to read
because the information doesn’t need a constant update. from a or write to. One can’t jump to the desired location
These memories are commonly used for cache memory. Sequential access is mostly used for mass storage of data.
This types of memory is very fast with access time is 15 to For example, information recorded on a reel of magnetic
30 nanoseconds but is physically bulky. tape is stored in sequential access form.
Some mass storage device such as floppy disk use a
Dynamic RAM (DRAM) : Dynamic random-access combination of random access and sequential access. Two
memory is an improvement over the expensive and bulky major semiconductor technologies are used in integrated-
SRAM. DRAM uses a different approach to store data. circuit memory devices, which are used to build memory
Information is stored as charges in a very small capacitor. If system for today’s memory. There are bipolar and MOS
a charge exists in a capacitor, it’s interpreted as 1. The (metal-oxide semiconductor) technology.
absence of a charge will be interpreted as 0.
Because DRAM uses capacitors there is a chance of Bipolar memories: They are used with microprocessor
leakage of charge. Thus it needs to use a constant refresh systems. The advantage of bipolar memories is then very
signal to keep the information in the memory (every few fast access time. They have a number of disadvantages when
millisecond). DRM technology allows several memory compared with MOs memories. They draw a great deal of
units, called cells to be packed at very high density. power, and there are fewer memory bits for the same silicon
Therefore, these chips can hold very large amount of chip size. The fabrication is much more complicated and
information. Most PCs today use DRAM. Access time for thus are much more expensive than Mos memories. For
DRAM is 80 nanoseconds or more, slower than SRAM, and these reasons bipolar memory is used only for applications
two or three times faster than ROM. which can afford its great cost.
The memory can be classified even as: random access
memory and sequential access memory. MOS Memory: It is the most common microcomputer
The term random-access memory simply means a memory memory. The Mos memory cells are structurally simple and
system in which any memory location can be accessed as economical. The MOS cell needs an area of about 25% to
Downloaded from www.jayaram.com.np 29 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
50% of the area required by the bipolar cell. Hence they can - The D and D’ are data lines. There is external driving
be more densely packed. Mos cell consume much less power circuitry which forces D and D’ to opposite values.
than bipolar cells. When reading the bit from the cell the D and D’ serve
as output lines, while writing a bit on the cell they
Today’s RAM cell are, in common of two types depending serve as forced input.
upon the storage elements. MOS technology is applied in - Before reading or writing on cell, the cell must be
both cases. These are selected, and the select line is used for the purpose.
- Static RAM cell
- Dynamic RAM cell. Working on Cell:
- The access transistor QA’s are turned on via the row
Static RAM Cell: select line (high).
- The data lines are forced into a state with D high and
+VDD D’ low.
- The MOSFET Q1 will be turned on and Q2 off.
- When forcing signals are removed Q1 will continue to
Q3 Q4 hold D’ low (i,e Q1 will be on) and will keep Q2 off
and D output high.
QA QA - The forced state is thus self-sustaining and stable.
D D
A similar stable state exists with D low and D’ high. For
either cases, the stored data will be hold by the flip-flop
Q1 Q2 until it is either changed by new forcing singles. Or until
the power to the ckt is removed.
Select line
Fig. static RAM cell Reading from Cell:
- QA’s are turned on via select line ( high).
- The figure above shows a NMOS static memory cell - The stored data appears on D’ and D respectively
which consists of six NMOS transistors. from Q1 and Q2.
- The transistors QA, is called the access transistors are
used to access the data during the read and write
operation.
- The transistors Q3 and Q4 are pull up load transistors
and their cross connection with Q2 and Q1
respectively forms a flip flop.
Downloaded from www.jayaram.com.np 30 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
Dynamic RAM Cell: 2. Power consumption is low.

The disadvantage is :
- The storage capacitor cannot hold its charge over an
extended period of time and losses the stored data bit
Select line
unless its charge is refreshed periodically.
Q
- This process of refreshing requires additional memory
circuitry and complicates the operation of the dynamic
Cs (storage Capacity) RAM.

Data line Interfacing Devices:


Fig. Dynamic RAM cell These devices are semiconductor chips that are
needed to connect peripherals to the bus system. Several
The figure above shows a dynamic RAM cell which consists type of interfacing devices are necessary to interconnect the
of one MOSFET and one capacitor. component of a bus oriented system. The commonly used
- The capacitor is to store the bit. devices are tri-state , buffer, encoder, decoder and latches.
- The transistor acts as a switch.
Tri- state devices: In general a logic device has two states:
Write Operation: logic 1 and logic 0. The tri-state device has a third state too,
- The data line is high (to store 1) high impedance state. The devices has a third line (other
- The select line is high. than input and output) called enable. When this line is
- The MOSFET is turned ON and the capacitor is activated, the tri-state device functions the same way as
charged. ordinary logic devices. When the third line is disabled, the
- When data and selection line goes low the MOSFET logic device goes into the high impedance state as if it were
open (turns off) and the capacitor retains its charge. disconnected from the system. Ordinarily , current is
required to drive a device in logic 0 and logic 1 states. In
Read Operation: the high impedance state 1 practically no current is drawn
- The select line is high. from the system.
- The data in the capacitor is then received at the data
line. Input Output
Input Output

The advantage of this types of cell are: Enable (active high) Enable (active low)
1. Very simple , allows very large memory arrays to be
Fig. tri-state buffer
constructed on a chip at a low cost per bit.
Downloaded from www.jayaram.com.np 31 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
combination of two buffers in different direction combines
In a micro-compurter systems, peripherals are connected in to form a bi-directional buffer. The bi-directional buffer
parallel between the address bus and data bus. However 47LS245 is a typical example and is used commonly as a
because of tri-state interfacing devices, peripherals do not driver for the data bus.
load the system buses. The microprocessor communicates
with one device at a time by enabling the tri-state line of the Input/Output Output/input
interfacing device. Tri-state logic is critical to proper
functioning of the microcomputer.

Buffer: The buffer is a logic ckt that amplifies the current or


power. It has one input line and one output line. The logic Enable
level of the output is same as hat of the input; logic 1 input
provides logic 1 output. The buffer is used primarily to Fig. Bidirectional buffer
increase the driving capability of a logic circuit. It is also
known as driver. Decoder: The decoder is a logic ckt that identifies each
combination of the signals present to its input. If the input to
Input Output a decoder has n lines, the decoder will have 2n output lines.
Fig. A buffer For example if the input has two binary lines the output lines
would be 4. The two lines can assume four combinations of
Tri-state buffer: This is the buffer with a third line enable input signals. – 00, 01, 10, 11 – with each combination
to activate the device. When the line is activated it acts as an identified by the output lines 0 to3. If the input is 11, the
ordinary buffer when disabled the buffer goes into high output logic 3 will be at logic 1 and otherwise will remain at
impedance state. This buffer in commonly used to increase logic 0 . This is called decoding . Various types of decodes
the driving capability of the data bus and the address bus. are available; for example 3 to 8 , 4 to 16 , etc. In general
Input Output
decoders have enable lines too. The decoder will not
function unless enable lines are activated.
Enable (active low)

As the address bus is unidirectional, this device is


commonly used as a driver. The octal buffer 74LS244 is a
typical example of a tri-state buffer.
The data bus of a µc is bi-directional , therefore it requires
a buffer that allows data to flow in both directional. A
Downloaded from www.jayaram.com.np 32 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
with keyboards. For each key pressed, the corresponding
3
binary code is placed on the data bus.
2 Output
Input 2-to-4
Decoder 1
0
Latches: A latch is used commonly to interface output
devices. When the µPU sends an output, data are available
on the data bus for only few micro-seconds ; therefore a
latch is used to hold data for display.
In its simples form, a latch is a D flip flop. We are having
Enable
other latches( flip flops) like; RS flip flop, JK flip flop and
7
6
Master slave flip flop etc.
5
Output
Flip flop even form a cell of memory.
Input 3-to-8 4
Decoder 3
2
1
0

Internal structure of memory:


Enable The internal structure of a 8 × 8
memory is shown below. Every memory unit has the similar
Encoder: The encoder is a logic ckt that provide the types of structure.
appropriate code( binary, BCD etc) as output for each input
signal. The process is the reverse of decoding . Figure below
shows an 8 to 3 encoder; it has eight active low inputs and
three output lines.

7
6
5
A2
4
Input A1 Output
3
2 A0
1
0

When 0 goes low , the output is 000, when the input line 5
goes low the output is 101. Encoder are commonly used
Downloaded from www.jayaram.com.np 33 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
I7 . . . . . . . . . . . . . . . . . . . . . . . . . . I0

The number of address lines will be determined by the


CS memory capacity. The number of data lines will be
Input buffer
WR determined by memory size. For example for memory
capacity 1k× 8 will have 10 address lines and data lines. 2k
111 Register 7 × 4 chip will have 11 address lines and 4 data lines. For 2n k
110 × m memory capacity the number of address lines = n and
Register 6
101
number of data lines = m.
Register 5
100
A2
Register 4 Let’s consider the 8 × 8 memory device with 8 register , a 3
A1 011 Register 3
to 8 decoder, an input buffer and an outpur buffer. The
device will have 3 address lines and eight data lines. It will
A0 010
Register 2 also have control lines RD , WR and CS .
001 - To write an 8 bit word the µp places the register
Register 1
000 address on the three address line e.g to write in the
Register 0
register 7, µp places 111 on the address lines.
- The decoder decodes the address and selects the
Output buffer
CS register 7.
RD - Then the µp places the data on the data bus and sends
the active low WR control signal.
O7 . . . . . . . . . . . . . . . . . . O0 - The control signal enables the input buffer and data
Data lines
are placed in the selected register.
Fig. A 8×8 memory unit
- To read from this memory, the process is similar to
that of write operation except that output buffer is
enabled with RD active low signal.
Internally a memory consists of:
- The remaining address lines of the µp address bus are
~ address decoder
used to select the chip ( CS ).
~ input buffer
~ output buffer
~ registers
With Basic concept in memory interfacing:
~ address lines
~ data lines The primary function of memory interfacing is that
two microprocessor should be able to read from and write
~ RD , WR , CS control lines.
Downloaded from www.jayaram.com.np 34 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
into a given register of a memory chip. To perform this remaining address line ( A15 – A11) should be decoded to
operation the micro processor should. generate a chip select ( CS ) signal unique for that chip.
1. Be able to select the chip The remaining five lines are connected to the decoder ( 3 to
2. Identify the register. 8 decoder) as shown is the figure above.
3. Enable the appropriate buffer. - The decoder is enabled by IO / M signal is addition to
address lines A15 and A14
Let us consider a RAM chip (6.6) to be interfaced with 8085 - The output O1 of the decoder is connected to CS of the
µP. The interfacing ckt is shown below: memory chip.
- The input line lines to the decoder are A15, A12, and
A14 A15
RD A11. These activate the output O1 to select the memory
IO/M WR chip.
E1 E2 E3
A10
CS OE WE - Thus to select the memory chip we must have the
A13
3 - to - 8 6//6 output O1 to selected by the 3 to 8 decoder, which
A12
A11
decoder RW memory
2048×6
means we need A13 = 0
A0 A12 = 0
O1
A11 = 1
Data lines
- Also to enable the 3 to 8 decoder we need IO / M low
and A14 = 0 , A15 = 1
D7 . . . . . D0
Thus the chip is selected by ‘10001’ at lines A15 – A11 of
the address bus. And hence the range of address for the
memory chip would be
Fig. Interfacing R/W memory 10001 00000000000 = 8800 H
10001 11111111111 = 8FFF H
For interfacing the chip with 8085 µp we just need and
additional 3 to 8 decoder to select the chip. The register Thus for interfacing the 6116 ( RAM chip) the – 8 data lines
inside the chip can be identified by the internal address of µp are connected to 8- data lies of the chip.
decoder and input or output buffers can be enabled by the
control signals RD or WR . - The lower address lines A10 – A0 are connected to that
of the chip.
The memory chip 2048 × 8 requires 11 address lines - The higher address lines A15 – A11 are connected to
to identify the 2048 register. Therefore the lower address the 3-to-8 line decoder.
lines A10 – A0 form the µP are connected to the chip. The - The chip is selected by the output O1 of the 3-to-8 line
decoder being connected to the CS pin of the chip.
Downloaded from www.jayaram.com.np 35 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
Similarly the EPROM can be interfaced with 8085. The only I/O interface:
difference would be, there would be no WR lines connection, Input and output interfaces provide a method
as this memory is not used for write operation. The for transferring information between internal storage and
interfacing is as shown below. external I/O devices. Peripherals connected to a computer
+5v
MEMR need special communication links for interfacing them with
A15 central processing unit. The purpose of the communication
E1 E2 E3 CS OE link is to resolve the difference that exist between the
A14 A11
2732
processor and each peripheral. The major differences are:
A13 3 -to- 8 EPROM
A12 Decoder 4096×8
O1
A0 1. Peripherals are electromechanical and electromagnetic
devices and their manner of operation is different
form the operation of the CPU and memory, which
Data bus
are electronic devices. Therefore a conversion of
D7 . . . . . D0 signal value may be required.
2. The data transfer rate of peripherals is usually slower
Fig. interfacing 2732 EPROM than the transfer rate of the CPU, and consequently a
synchronization mechanism may needed.
Four interrupts TRAP, RST 7.5, 6.5, 5.5 are automatically 3. Data codes and formats in peripherals differ from the
vectored (transferred) to specific locations on without any word format in the CPU and memory.
external hardware. They do not require INTA signal or an 4. The operating modes of peripherals are different from
input port; the necessary hardware is already implemented each other and each must be controlled so as not to
inside the 8085. These interrupts and their call locations are: disturb the operation of the other peripherals
connected to the CPU.
Call locations To resolve these differences computes systems include
TRAP 0024 H special hardware components between the CPU and
RST 7.5 003C H peripherals to supervise and synchronize all inputs and
RST 6.5 0034 H outputs transfers. These components are called interface
RST 5.5 002CH units because they interface between the processor bus and
peripheral devices. The two major types of I/O interface
The TRAP has the highest priority, followed by RST 7.5, are:
6.5, 5.5 and INTR. Figure below shows the schematic 1. Serial interface.
diagram of 8085 Interrupts. 2. Parallel interface.

Downloaded from www.jayaram.com.np 36 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
Serial interface: A serial interface exchanges data with the point B to point A as shown in figure below. Physically two
peripheral in serial mode, where data are transmitted one bit wire are required for transmission of data. One is signal wire
at a time along a simple communication link. Serial and other is ground return wire.
transmission is slow but inexpensive to implement as far as
A B
the number of wires is connected.
The function of serial I/O interface Transmitter Receiver
is to deal with the data on the bus in the parallel mode and to
communicate with the connected device in the serial mode. Fig. Simplex mode
If the bus has n data lines the serial i/o interface accepts n
bits of datas simultaneously form the bus . These n bits are
put to the I/O devices one bit at a time requiring n time slot The half duplex mode: This mode is also known as two
for transmission. The reverse process takes place during way alternate transmission. This mode allows the
reception of data form the device. transmission of data over a single channel in both directions
but not simultaneously. In this mode too, just two wires are
Parallel interface: Some I/O devices can handle data at required, but additional circuitry is needed to determine and
speeds that can not be supported with serial interfaces so establish the direction of flow of information..
such a case a parallel interface must be used, where n bits of
the data are handled simultaneously by the bus an on the A B

links to the device. This achieves a faster interchange of data Receiver


Transmitter
but becomes expensive due to the need of multiple wires. If Channel
any I/O devices particularly those requiring high data OR
transfer rate use this arrangement.
Receiver Transmitter

Communication can be broadly defined as an unilateral or Channe2

bipolar transfer of meaningful data between two points


through a mediums. Communication can be in Fig. Half duplex mode
1. Simplex mode
2. Half duplex mode
3. Full duplex mode. The full duplex mode: This mode allows the transmission
of data in both directions simultaneously but on two separate
The simplex mode: This mode allows the transmission of channels. Two signal wires and two ground return wires are
data over a single channel in one direction only. The data required in this mode. A disadvantage of this mode is the
can be transmitted only from point A to point B not form additional cost of the second channel. It is however possible

Downloaded from www.jayaram.com.np 37 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
to offer simultaneously two way communication on a single impractical over long distances because of prohibitive cost
channel using complex circuitry. of installing a large number of lines.
Channel
Transmitter Receiver
Serial data transfer: In serial data transfer, each bit of the
word is sent in succession, one at a time over a single pair of
Channe2 wires. A parallel to serial converters is used to convert the
Receiver Transmitter
incoming parallel data to serial form and then the data is sent
out with the lest significant bit Do first and most significant
Fig. Full duplex mode bit D7 coming last of all. If the bit rate is retained after the
parallel to serial conversion, the time taken to transmit a
Method of communication: word in serial data transmission will be n times more than
the time taken in parallel data transmission. If the word in
Parallel data transfer: When a word of n bits is to be the above example were to sent serially, the data on the
transmitted in parallel each bit is transmitted on a separate channel will appear as in figure below.
line along with a common ground line with respect to which
the status of each line is measured. Thus, a channel Word 3 to be generated
Word 2 Word 1
comprises of (n+1) lines.
1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
Transmitter Receiver

101
D0
110
001 Fig. serial data transfer
010
101
Transmitter 110 Receiver
001
010
D7 There are tow types of serial transfers. They are:
1. Asynchronous serial data transfer.
2. Synchronous data transfer.

Asynchronous transfer:
Fig. parallel data transfer In this types of transmission, the
receiving device does not need to be synchronized with the
Here, the time required to transfer one word is equal to the transmitting device. The transmitting device can send one or
time taken to transmit a bit. Parallel data transmission is more data units when it is ready to send. Each data unit must
Downloaded from www.jayaram.com.np 38 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
be formatted. In other words, each data unit must contain ‘a the transmitter sends out a stop bit which is the idle value (
start bit’ and ‘stop bit(or bits)’ indicating the beginning and logic 1) to indicate the end of transmission.
the end of each data unit . In asynchronous transmission the
data message is sent one word at a time. From
Transmitter data start
To receiver
- When no datas are sent over the time it is maintained stop
bit
D7 D6 D5 D4 D3 D2 D1 D0
at an idle value; a logic 1. bit

- Start bit is a logic 0.


- The stop bit is a logical 1. Fig. Transmission format for Asynchronous transfer

Asynchronous communication is a start-stop type of


Both the transmitter and receiver are given separate clocking communication and is used where the source of data may
signals. It is not essential that they both be of exactly the not be providing a steady stream of new characters. The
same frequency. The data is sent out of the transmitter data thus comes to the receiver at unevenly spaced intervals
synchronous with its own clock input and the data is without reference to a master clock, hence the name
similarly received and assembled at the receiver. Asynchronous.

Asynchronous transmission: Synchronous communication


1 1
Start IDLE Start
1 1 1 1
Start
IDLE is used for transferring large amount of data at a stretch
0 0 0 0 0 0
Transmitter Receiver without frequent start or stops. In synchronous systems to ,
CLK CLK the line is maintained at the idle value when no data is being
transmitted. The transmission begins with a block header
which is a predetermined pattern of bits. The receiver
Fig. Asynchronous communication. identifies the pattern and gets ready to receive the
characters.
When a character is to be transmitted, the transmitter first The transmitter sends the data character by character, bit by
sends out a low bit. This transition is perceived by the bit. After sending all the characters, the transmitter sends
receiver and it gets ready to receive the data. another pattern of bits to indicate the end of transmission.
Postamble Preamble
The transmitter then sends out the word bit by bit, one after
From To receiver
the other, synchronous with its clock. Transmitter sync.sync sync sync
The receiver assembles the data one by one synchronous data
with its clock. The receiver must known beforehand the Fig. Transmission format for synchronous transfer
transmission ‘Baud Rate’(bits per seconds) for proper
assembling at its end. After all the bit of a character are sent,
Downloaded from www.jayaram.com.np 39 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
This format is generally used for high speed transmission ( referred as data communication equipment (DTE). The data
more then 20 kbps). Here the receiver and transmitter are terminal equipment (e.g a microcomputer) is capable of
synchronized by a master clock i.e both function depending sending and/or receiving data via the serial interface. The
upon the same clock signal. data communication equipment on the other hand is
generally through of as a device which can facilitate serial
data communications (e.g modems).
Baud Rate: The rate at which the bits are transmitted (bits
per seconds) is called a baud; technically, however it is - RS 232C works in a negative logic. The standard
defined as the number of signal changes/ second. Each piece specifies that ‘the logic one’ level is a voltage
of equipment has its own band requirements. between -3 and -15 v and ‘the logic zero’ is a voltage
between +3 and +15 V. The commonly used voltages
are +12v and -12V.
Bus Interface standards: The microcomputer is a bus - The transmission line normally used a twisted pair of
oriented system where by subsystems or peripherals are shielded wire with a line capacitance of more than
interconnected through the bus architecture. Peripheral and 1200PF and no less than 300Pf. The standard
computers are designed and manufactured by various specifies the line length to 50 feets only.
manufactures. Therefore, a common understanding must exit - The standard describes the function of 25 signal and
, among various manufacturing and user groups, that can hansake pins for serial data transfer. It also specifies
ensure compatibility among different equipment. When this that the DTE connector should be male and the DCE
understanding is defined and generally accepted in industry ( connector should be female. Usually 9 pin and 25 pin
and by users) , it is known as a standard. In the field of connectors are available.
electronics, these standards are generally defined by
professional organizations such as IEEE; EIAC ( Electronic Among the 25 pins of RS232C the independent pin numbers
industries Association or the standards are forced upon the are:
industry either by a dominant manufacturer or by common
practice. Various bus standards are defined till now. We Pin no. Signals Functions
would be dealing RS 232C and GPIB here. 2 Transmit data, TXD Output ,
transmit data from DTE to DCE
RS 232C: This interface standard is most widely used 3 Receive data RXD Input, DTE receive
standard for serial communication between microcomputers data from DCE
and peripheral devices. The interface, defined by EIA, 4 request to send, RTS General purpose
relates essentially to two types of equipment. The first is output from DTE
known as data terminal equipment. While the second is
Downloaded from www.jayaram.com.np 40 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
RS 232C cable
5 Clear to send,CTS Input to DTE, used as Transmit
receive
handshake
TTL MC 1488 MC 1489
TTL
6 Data set ready, DSR Input to DTE, 2 2
indicate that DCE is ready DTE MC 1489
receive 3
MC 1488 DCE
3
7 Singal ground,GND Common AND AND
7 7
reference bet. DTE and DCE
Transmit
8 Data carrier detect, DCD Used by DTE to Fig. RS 232C interface
disable data reception
20 Data terminal ready, DTR Output means The signaling in RS-232C is not compatible with the TTL
DTE is ready. logic level. For TTL 0 v to 0.2V is considered a logic 0 and
3.4 v to 5v as logic 1. But RS-232C works in a negative
The main problem with –RS-232C is that it can only transfer logic -3 to -15v considered as logic 1 and +3 to +15v as
data reliably about 50ft (16.4m) at its maximum rate of 20k logic 0. Because of this incompatibility of the data lines with
band. If longer lines are used the transmission rate has to be the TTL logic, voltage translators called line drivers and line
drastically reduced. For higher rate of transfers and for receivers are required to interface TTL logic with RS-232C
longer distance we have another standards defined. signals.
The line driver MC 1488 converts logic 1 into approx -9V
Standards Speed Distances Voltage Range and logic 0 into +9v. Before it is received by the DCE it is
RS 232C 20k band 50ft ± 15V
again converted by the line receiver MC 1489 into TTL-
RS-422A 10Mbaud at 40ft 4000ft ±7
Compatible logic.
100 Kbaud at 4000ft The minimum interface required both a computer and a
RS-485A 100K baud at 30ft peripheral device requires three lines; pin 2,3 and 7. These
1 kbaud at 4000ft 4000ft ± 12V
lines are defined in relation to the DTE; the terminal
transmits on pin 2 and receives as pin 3. On the other hand
the DCE transmits on pin 3 and receives on pin 1. Pin 7 is
RS 232C interface with DTE and DCE: The figure below ground pin.
shows a interfacing with minimum lines.

GPIB ( General purpose instrumentation bus ) ~ IEE-


488 standard
~ HPIB (Hewlette puckard interface bus)

Downloaded from www.jayaram.com.np 41 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
This is the most widely used industrial bus format. It was Talkers/ listners: Talkers and listners can both send and
developed to facilitate interface of computers with various receive data to/from the bus. A digital multimeters is a
instruments as – printers, tape recorders, digital voltmeters, typical example. Data is sent to it in order to change ranges
frequency counters, function generators etc. Some of the and returned to the bus in the form of digitized readings of
features of this bus are: voltage, current and resistances.
1. Data transfer among the interconnected devices in
digital format. Controller: controllers are used to supervise the flow of
2. Allows 8 bit parallel bi-directional communication. data on the bus and provide processing facilities. The
3. Fifteen devices may be connected to one controller within an IEE-488 system is a microcomputer.
continuous bus.
4. Total transmission path is limited to 20 metres or I/O ports addressing: A number of microprocessor have
two meters per device. distinct memory and I/O address spaces. These processors
5. Data transfer rate on any single line is limited to generally have special instruction to access a port. A
1M-byte/sec separate control line is used to distinguish between I/O and
6. The bus as 24 signals: eight bidirectional data memory operations. In 8085 IO/ M line is used for this
lines. purpose. The address of the I/O port (XXH) is put on both
: eight control lines. the lower and upper eight lines of the address bus during T1
: eight ground lines. of the machine cycle. I/O device can be interfaced to an
CO85A system in two ways: 1. I/O mapped I/O mode
This standard describes four types of devices which may be 2.Memory mapped I/O mode.
interface to GPIB.

a. Listners: These devices can receive data band I/O mapped I/O mode (standard I/O): In this mode, the
control signals from other devices connected to the IO/ M signal of the 8085A is used to distinguish between
bus but are not capable of generating data. e.g I/O read/write and memory Read/write operations. The I/O
printers. device an be accessed during IN and OUT instructions ( a 1
b. Talkers: These devices are only capable of placing byte address is specified in the instruction).
data on the bus and can not receive data. Only one
talker can be active at a given time but fourteen Memory mapped I/O mode: In this mode the IO/M signal
devices can listen at a time. Example for talkers are: output is not used to distinguish between memory and I/O
scanners, tape readers, voltmeters etc. devices. The microprocessor communicates with an I/O
device as if it were one of the memory location. Hence the
I/O devices are address as memory.
Downloaded from www.jayaram.com.np 42 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np

Interfacing: The objective of interfacing an output device is


D7
to get information or a result out of the processor and to
display it, similarly the input device is interfaced to get 74LS373 +5v
octal
information into the processor. To do that three common latch
steps are undertaken. A7
74LS30
IOADR D0

1. Decode the address bus to generates a unique pulse 74LS02

corresponding to the device address on the bus; this is A0

called I/O address pulse.


2. Combine (AND) the device address pulse with the IOW
control signal to generate a device select (I/O select)
pulse that is generated only when both signals are
applied. Here:
3. Use the I/O select pulse to active the interfacing - The address bus A7 – A0 is decoded by using an 8
device (I/O ports) input NAND gate.
- The output of the NAND gate goes low only when the
The diagram below illustrates the steps: address line carry the address FF H.
- The output of the NAND gate combines with the
A1
Latch or microprocessor control signal IOW in a NOR gate
Data bus buffer (connected as a negative AND). The output of NOR
Decoder

A0 IOADR
gate (74LS02) goes high to generate on I/O select
AND pulse when both inputs are low(or both signals are
Enable
OISEL asserted).
- Mean while the contents of the accumulator have been
IOR IOW
put on the data bus.
The address lines A7 – A0 are connected to a decoder which - The I/O select pulse is used to activate the latch and
will generate a unique pulse corresponding to each address data are latched and displayed on the diodes.(LEDs)
on the address lines. This pulse is combined with the control
signal to generate a device select pulse. Which is used to
enable an output latch or an input buffer. Interfacing an Input device (DIP switches): The figure
below shows an input interfacing ckt for DIP switches.
Interfacing output display: The figure below shows an
output interfacing ckt for LED display.
Downloaded from www.jayaram.com.np 43 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
+5v
SOD: The instruction SIM is necessary to output data
serially from SOD line. It can be interpreted for serial output
A6
0
1
as below:
0 D7
A5 1
0 1
A4
0 1 D7 D6 D5 D4 D3 D2 D0 D1
A3 Octal
Data 1
bus Buffer
0 SOD SDE X
0
E1 E2 E3 0 For interrupts
1 D0
A2
0 3-to-8
A1 Serial
0 decoder IOADR
1= enable SOD
A0 output 0= disable SOD
data
IOR

Here: SID: The instruction RIM is used to input serial data


- The address bus A7 – A0 is decoded using an decoder. through the SID line. It can be interpreted for serial input as
- The output of the decoder (O4) goes low only when below.
the address line carry the address 84H. D7 D6 D5 D4 D3 D2 D1 D0
- The output of the decoder combines with the µP SID

control signal IOR in a negative NAND gate. The Interrupts status


output of this gate goes low to generate an I/O select
pulse when both inputs are low. Serial input data

- The I/O select pulse is used to activate the buffer and


the data from the DIP switches (F8H) is put on the
data. SID and SOD lines eliminates the use of input and output
port in the software controlled serial I/O. SID is a 1-bit input
The 8085- serial I/O lines: SOD and SID: port and SOD is a 1-bit output port.
- The 8085 µP has two pins specially designed for
software controlled serial I/O. One is called SOD Interrupt:
(serial output data) and the other is called SID(serial An interrupt is a signal that a peripheral board sends to the
input data). central processor in order to request attention. In response to
- Data transfer is controlled through two instructions: an interrupt, the processor stops what it is currently doing
SIM and RIM and executes a service routine. When the execution of the
service routine is terminated, the original process may
resume its previous operation.

Downloaded from www.jayaram.com.np 44 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
The interrupt is initiated by an external device and is 5. The processor then loads the program counter with the
asynchronous, meaning that it an be initiated at any time entry location of the interrupt service routine that will
without reference to system clock. However , the response to respond to this interrupt. Once the program counter
an interrupt request is directed or controlled by the has been loaded, the control is transferred to the
microprocessor. interrupt handler program.
6. The fundamental requirement of the interrupt service
Interrupts are primarily issued on: routine is that it should begin by saving the contents
~ initiation of I/O operation. of all the registers on the stack( as state of the main
~ completion of I/O operation. program should be safe).
~ occurrence of hardware or software errors. Suppose the user program is interrupted after the instruction
at location N. The contents of all the registers plus the
Process of interrupt operation: address of the next instruction are saved on the stack. The
1. The I/O unit issues an interrupt signal to the stack pointed is updated and the programs counter is updated
processor. An interrupt signal from I/O is the request to point to the beginning of the interrupt service routine.
for exchange of data with the processor. 7. The interrupt handler now proceeds to process the
2. The processor finishes execution of the current interrupt. This will include an examination of status
instruction before responding to the interrupt. information relating to the I/O operation or the other
3. The processor testes for an interrupt, determines that event that caused an interrupt. It may also involve
there is one, and sends an acknowledgement signal to sending additional commands or acknowledgement to
the device that issued the interrupt. After receiving the I/O unit.
this acknowledgement, the device retains its interrupts 8. When interrupt processing is complete the saved
signal. register’s value ( of the main program) are retrieved
4. The processor now begins to transfer the control to the from the stack and restored to the register.
routine which serves the interrupt request from the 9. The final function is to restore the PSW and program
device. This routine is called ‘Interrupt service counter values from the stack. As a result the next
routine’ and it resides at a specified memory location. instruction to be executed will be from the previously
For this process, the CPU needs to save information needed interrupted main program.
to reassume the current program at the point of interrupt.
The minimum information required is i) the status of the Types of interrupt:
processor, which contained by the processor status word There are three major types of interrupts that
(PSW) and ii) the location of the next instruction to be cause a break in the normal execution of a program. They
executed which is contained by the program counter (PC), can be classified as:
these all are pushed onto the stack.
Downloaded from www.jayaram.com.np 45 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
1. External interrupts priority over the maskable interrupt. This means that if both
2. Internal interrupts the makable and non maskable interrupts are activated at the
3. Software interrupts. same time, then the processor will service the non-maskable
interrupt first. In 8085 TRAP is an example of non maskable
External interrupts: External interrupts are initiated via interrupt.
the microprocessor’s interrupt pins by external devices such
I/O devices, timing device, circuit monitoring the power Internal interrupt: Internal interrupt arise form illegal or
supply etc. Causes of these interrupts may be; I/O device erroneous use of an instruction or data. Cause of this
requesting transfer of data, I/O device finished transfer of interrupt may be: register overflow, attempt to divide by
data, elasped time of an event, or power failure. Timeout zero, an invalid operation code, stack overflow etc. These
interrupt may result from a program that is an endless loop error conditions usually occur as a result of premature
and thus exceeded its time allocation. Power failure interrupt termination of the instruction execution. These are even
may have as its service routine a program that transfers the termed as exceptions.
complete state of the CPU into a non-destructive memory in The difference between internal and external interrupt is
few milliseconds before power ceases. that the internal interrupt is initiated by some exceptional
conditions caused by the program itself rather than by an
External interrupts can be further divided into two types: external events. Internal interrupts are synchronous with the
1. Maskable interrupt. program, while external interrupts are asynchronous. If the
2. Non-maskable interrupt. program is return, the internal interrupt will occur in the
same place each time. External interrupts depends on
Maskable interrupt: A maskable interrupt is one which external conditions that are independent of the program
cab be enabled or disabled by executing instructions such as being executed at the time.
EI ( enable interrupts)and DI (Disable interrupt). If the
microprocessor’s ‘interrupt enable flip flop’ is disabled, it Software interrupt: External and internal interrupts are
ignores a maskable interrupt. In 8085, the 1 byte instruction initiated from signal that occur in the hardware of the cpu. A
EI sets the interrupt enable flip flop and enables the interrupt software interrupt is initiated by executing an instruction.
process. Similarly the 1 byte instruction DI resets the Software interrupt is a special call instruction that behaves
interrupt enable flip flop and disables the interrupt process. like an interrupt rather than a subroutine call. It can be used
No maskable interrupts are recognized by the processor by the programmer to initiate an interrupt procedure at any
when the interrupt is disabled. desired point in the program. The most common use of
software interrupt is associated with a supervisor call
Non maskable interrupt: This type of interrupt cannot be instruction. This instruction provides means for switching
enabled or disabled by instructions. This types has higher from a CPU user mode to the supervisor mode. Certain
Downloaded from www.jayaram.com.np 46 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
operations in the computer may be assigned to the There are mainly two ways of servicing multiple interrupts.
supervisor mode only, as for example, a complex input or These are:
output transfer procedure. In 8085 the instruction like RST0, 1. Polled interrupt.
RST1, RST2, RST3…..etc. causes a software interrupt. 2. Chained (Vectored) interrupt.

Interrupt priority: Data transfer between the CPU and an Polled interrupt: Polled interrupt are handled using
I/O device is initiated by the CPU. However , the CPU software and are therefore slower compared to vectored
cannot start the transfer unless the device is ready to (hardware) interrupts. In this method there is one common
communicate with the CPU. The readiness of the device can branch address for all interrupts. The program that takes care
be determined from an interrupt signal. The CPU responds of interrupts begins at the branch address and polls the
to the interrupt request by storing the return address form interrupts sources in sequence. The order in which they are
PC into a memory stack and then the program branches to a tested determines the priority of each interrupt. The highest
service routine that process the required transfer. priority source is tested first, and if its interrupt signal is on,
In micro-computer a number of I/O device are attached to control branches to a service routine for this source. Other
the processor, with each device being able to originate an wise the next lower priority source is tested, and so on.
interrupt request. The first task of the interrupt system is to Thus, the initial service routine for all interrupts consists of a
indemnify the source of the interrupt. There is also the program that test the interrupt sources in sequence and
possibility that several sources will request service branches to one of many possible service routines.
simultaneously. In this case the system must also decide Polled interrupts are very simple . But or large number of
which device to service first. devices, the time required to poll each device may exceed
An interrupt priority is a system that established a the to service the device. In such case, the faster mechanism
priority over the various sources to determine which called chained interrupt is used.
condition is to be serviced first when two or more request
arrive simultaneously. The system may also determine Chained interrupt: This is hardware concept of handling
which conditions are permitted to interrupt the computer the multiple interrupts. In this technique, the devices are
while another interrupt is being serviced. Higher-priority connected in a chain fashion as shown in figure below for
interrupt levels are assigned to request which, if delayed or setting up the priority system.
interrupted, could have serious consequences. Device with
higher speed transfers such as magnetic disks are given high INT

priority, and slow devices such as keyboards receive low Processor Device 1 Device 2 Device 3 Device n
....
priority. When two devices interrupt the processor at the INTA
same time, the processor service the device, with the higher
D0 - D7
priority first.
Downloaded from www.jayaram.com.np 47 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
without any external hardware. They do not require INTA
Here the device with he highest priority placed in the fist signal or an input port; the necessary hardware is already
position, followed by lower priority devices. Suppose that implemented inside the 8085. These interrupts and their call
one or more devices interrupt the processor at a time. In locations are:
response, the processor saves its current status and then
generates an interrupt acknowledge (INTA) signal to the TRAP Call location
highest priority device, which is device 1 in our case. If this TRAP 0024 H
device has generated the interrupt it will accept the INTA RST 7.5 003 CH
signal from the processor; otherwise, it will pass INTA on to RST 6.5 0034 H
the next device until the INTA is accepted by the RST 5.5 002C H.
interrupting device.
Once accepted, the device provides a means to the The TRAP has the highest, followed by RST 7.5, 6.5, 5.5
processor for finding the interrupt address vector using and INTR. Figure below shows the schematic diagram of
external hardware. Usually the requesting device responds 8085 interrupts.
by placing a word on the data lines. With the help of
hardware it generates interrupts vector address. This word is
referred to as vector, which the processor used as a pointer INTR:
to the appropriate device service routine. This interrupt is maskable. It can be enabled by
This avoids the need to execute a general interrupt service instruction EI and can be disabled by instruction DI. The
routine first. So this technique is also referred to as vectored INTR interrupt requires external hardware to transfer
interrupts. program sequence to specific CALL locations. There are 8
numbers of CALL-Locations for INTR interrupt. The
hardware circuit generate RST codes for this purpose and
Interrupts of 8085: The 8085 has five interrupts: places that on the data bus externally.
i. TRAP When the microprocessor is executing a program, it
ii. RST 7.5 checks the INTR line (when interrupt enable flip flop is
iii. RST 6.5 enabled using EI instruction) during the execution of each
iv. RST 5.5 instruction. If the line is high and the interrupt is enabled,
v. INTR the microprocessor completes the currents instruction,
disabled the interrupt enable flip flop and sends a INTA
signal. The processor does not accept any interrupt requests
The four interrupts TRAP, RST 7.5, 6.5,5.5 are until the interrupt flip flop is enabled again.
automatically vectored (transferred) to specific locations on
Downloaded from www.jayaram.com.np 48 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
The signal INTA is used to insert a Restart (RST) 7 6 5 4 3 2 1 0
instruction, ( it saves the memory address of the next R7.5 MSE M7.5 M6.5 M5.5
SOD SDE X
instruction to the stack. The program is transferred to the cal
location.). The RST instruction and their call locations are :

Instruction Hex-code Call location Ingored RST7.5 0=available


RST6.5 1= masked
RST 0 C7 0000 RST5.5
RST 1 CF 0008
RST 2 D7 0010 Most set enable

RST 3 DF 0018 Rset RST 7.5, if 1 reset disable


If 1,bit 7 is output to serial output data
RST 4 E7 0020
Serial output data; ignored if bit 6 = 0
RST 5 EF 0028
RST 6 F7 0030
RST 7 FF 0038
Assuming that the task to be performed is written as a
subroutine at the specified location the processor performs a
- bit D3 is a control bit and should be 1 for bits D0 , D1,
task. This service routine includes the instruction EI to
and D2 to be effective.
enable the interrupt again and RE-instruction to retrieve the
- Logic 0 on D0, D1, and D2 will enable the
memory address where the program has interrupted. Then
corresponding interrupts and logic 1 will disable the
the execution goes to the main program again.
interrupts.
ii) The second function is to reset RST 7.5 flip flop.
TRAP:
Bit D4 is additional control for RST 7.5
It is a non maskable interrupt. It has the highest
- If D4 =1, RST 7.5 is reset. This is used to ignore
priority among the interrupt signal. It need not be enabled
RST 7.5 without servicing it.
and it cannot be disabled. When this interrupt is triggered
iii) The third function is to implement serial I/O. Bit
the program control is transferred to the location 0024 H
D7 and D6 are used for serial I/O and do not effect
without any external hardware or the interrupt enable
the interrupts.
instruction. TRAP is generally used for such critical events
as power failure and emergency shut off.
RST 7.5, 6.5, 5.5: These interrupts are maskable and are
enabled by software using instructions EI and SIM ( set
interrupt mask). The execution of the instruction SIM
enables/disables the interrupts according to the bit pattern of
the accumulator.
Downloaded from www.jayaram.com.np 49 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
7 6 5 4 3 2 1 0
SET Interrupt Mask (SIM) instruction:
SID I 7.5 I 6.5 I 5.5 IE M7.5 M6.5M5.5
- This is 1 byte instruction.
- Can be used for three different functions:
i). One function is set mask for RST 7.5, 6.6 and 5.5
interrupts. This instruction reads the content of the Interupt masks
1 = masked
accumulator and enables or disables the interrupts. Interupt enable
1 = enabled
Serial input Pending Interupt
Pending interrupts: data, if any 1 = pending
When one interrupt request is being served, other
interrupt may occur resulting in a pending request. When
more than one interrupts occur. Simultaneously the
interrupts having higher priority is served and the interrupts
with lower priority remain pending. The 8085 has an I/O interface:
instruction RIM using which the programmer can know the
current status of pending interrupts. This instructions gives 8255 programmable peripheral interface (PPI):
the current status of only maskable interrupts. A programmable peripheral interface is a multipart
device. The part may be programmed in a variety of ways as
Instruction RIM: required by the programmer. The device is very useful for
- Read interrupt Mask. interfacing peripheral devices. It has 3 8- bit ports, namely
- 1 byte instruction. port A, port B and port C. The port C has been further divide
- Can be used for the followings. into two of 4-bit ports, and port C upper and port C lower.
Thus a total of 4 ports are available, two 8-bit ports and two
a. To read interrupt mask. This instruction loads the 4-bit ports. Each part can be programmed either as an i/p
accumulator with 8-bits indicating the current status port or an o/p port.
of the interrupts.
b. To identify the pending interrupts. Bits D4, D5, and D6 PA0 – PA7 - 8 pins of port A
identify the pending interrupts . PB0 – PB7 - 8 pins of port B
c. To receive serial data. Bit D7 is used to receive serial PC0 – PC3 - 4 pins of port Clower
data. PC4 – PC7 - 4 pins of port Cupper.

Downloaded from www.jayaram.com.np 50 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
D0-D7 PA0 - PA7 Mode 2: Mode 2 is strobed bidirectional mode of operation.
CS PC4 - PC7 In this mode port A can be programmed to operate as a
RESET
Intel PC0 - PC3 bidirectional port. The mode 2 operation is only for port A.
A0 8255
PB0 - PB7
When port A is programmed in mode 2, the port B can be
A1
used in either mode 1 or mode 0. For mode 2 operation PC3
RD to PC7 are used for the control of port A.
Vcc
WR GND
8279 (Programmable keyboard/display interface): 8279
Operating modes of 8255: is a programmable keyboard interfacing device. It has been
8255 has 3 modes of operation which are selected by designed for the purpose of 8-bit µP . It has two sections
s/w. namely keyboard section and display section. The function
Mode 0 - Simple input/output of the keyboard section is to interface the keyboard which is
Mode 1 – Strobed input/output used as i/p device for the µP. The purpose of the display
Mode 2 – Bidirectional port. section is to drive alphanumeric displays or indication lights.
Some important features are: simultaneous - keyboard
Mode 0: In this mode of operation, a port can be operated as display operations, scanned sensor mode, scanned.
a simple o/p or i/p port. Each of the four ports of 8255 can Keyboard mode, 8 – character keyboard FIFO, 2 – key lock
be programmed to be either an i/p or o/p port. out or N – key roll over with contact debouched, single 16-
character display, dual 8 or 16 numerical display,
Mode 1: Mode 1 is strobed input/output mode of operation. programmable scan timing and mode programmable from
The port A and port B are designed to operate in this mode CPU.
of operation. When port A and port B are programmed in
mode 1, six pins of port c are used for their control. PC0,PC1 8279 block diagram:
and PC2 are used for control of port B which can be used as
input or output port. If the port A is operated as an input I/P Keyboard section: This section has eight lines ( RL0 –
or O/P port If the port A is operated as an input port. PC3, RL7)that can be connected to 8 columns of a keyboard, plus
PC4, and PC5 are used for its control. The remaining pins of two additional lines shift and CNTL/STB (control/strobe).
port C, i.e PC6 and PC7 can be used as either input or output. The keys are automatically debouched and the keyboard can
When port A is operated as an output port, pins PC3, PC6 operate in two modes; two-key lockout or N-key rollover. In
and PC7 are used for its control. The pins PC4 and PC5 can two-key lockout mode, if two keys are pressed almost
be used either as input or output. simultaneously only the first key is recognized. In the N-key
rollover mode, simultaneous keys are recognized and their
codes are stored in the internal buffer. It can also be set up
Downloaded from www.jayaram.com.np 51 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
so that no key is recognized until only one key remains be used, either as a group of eight lines or as two groups of
pressed. four, in conjunction with the scan line, for a multiplexed
This section also includes 8 × 8 FIFO RAM, that store display. The display can be blanked by using the BD line.
keyboard entries and provides IRQ (interrupt request). This section includes 16 × 8 display RAM.
Signal when FIFO is not empty.
MPU Interface section: This section includes eight
DB0 - DB 7
bidirectional data lines ( DB0 –DB7), one interrupt request
R D W R CS Ao IRQ
(IRQ) line, and 6 lines for interfacing , including the buffer
RESET address line (A0) .
CLK Data I/O
FIFO/
sens er
When A0 is high, signals are interpreted as control words or
Buffer control RAM
Status
status; when A0 is low, signals are interpreted as data. The
IRQ line goes high whenever data entries are stored in the
FIFO indicating the availability of data.
Internal data bus (8)
8251A programmable communication Interface:.
The 8251A is a programmable chip designed
Dis play 16× 8 Contro l&
8×8
FIFO/
Keyboard
Debounce
for synchronous and asynchronous serial data
Address Dis play Timin g sen ser
regi ster RAM Register RAM
and control communication, packed in a 28-pin DIP. Figure shows the
block diagram of 8251A. It includes 5 sections: Read/write
control logic, Transmitter, Receiver, Data bus buffer, and
Modem control.
Display Timing and
registers C ontrol
Scan R eturn
counter

shift
OUT AD0 - A3 SLo - SL3 R Lo - RL3 CNTL/S TB
OUT B0 -B3

Scan section: The scan section has scan counter and 4 scan
lines (SL0 – SL3). These 4 scan lines can be decoded using a
4- to – 16 decoder to generate 16 lines for scanning.

Display section: The display section has eight output lines


divided into two groups A0 – A3 and B0 –B3. These lines can
Downloaded from www.jayaram.com.np 52 Downloaded from www.jayaram.com.np
Downloaded from www.jayaram.com.np
D7 -D0 Tran sm itter
Data Transmit
Bus TxD Data
Buffer D7 - D0 Bu ffer
Buffer Regi ster

C/D = 0
RD o r WR

RESET TxRDY CS
CLK Transmit C/D R/w
Read/Write Control TxE con trol C /D= 1 Co ntrol
C/D WR
Control Log ic WR =0 Regi ster
RD
RD Logic
RESET 16
WR CL K

CS
Receive R eceiv er
DSR Buffer RxD
S tat us
DTR Modem R egist er
Control C/D= 1
CST RD = 0
RTS
RxRDY
Receive
Control RxC
SYNDET
CS - Chip select: when signal goes low, 8251A is selected
by MPU for communication.
The control logic interfaces the chip with the MPU. The C / D - control/ data: When this signal is high , control
transmitter section converts a parallel word received from register or the status register is selected. When low data
MPU into serial bits and transmit them over the TXD line to buffer is addressed.
a peripheral. The receiver section receives serial bits from a
peripheral, converts them into a parallel word and transfers CS C/D RD WR Function
back to the MPU. The modern control is used to establish 0 1 1 0 MPU writes inst into control reg
data communication through modems over telephone lines. 0 1 0 1 MPU reads status from status reg.
0 0 1 0 MPU o/ps data to the data buffer
Read/ control logic and registers: This section includes R/W 0 0 0 1 MPU accepts data from data buffer.
control logic , six i/p signals, and 3 buffer registers: data 1 X X X USART is not selected
register, control register and status registers.
Transmitter Section:

Downloaded from www.jayaram.com.np 53 Downloaded from www.jayaram.com.np


Downloaded from www.jayaram.com.np
into a stream of serial bits. The MPU writes a byte in the
buffer register; whenever the o/p register is empty, the
contents of the buffer register are transmitted to the o/p
register. This section transmits data on the TxD pin with the
start and stop bits.

Receiver section: The receiver accepts serial data on the


RxD line from a peripheral and converts them into parallel
data. This section has two registers; the receiver i/p register
and the buffer register. When RxD line goes low, the i/p
register accepts the data and loads it into the buffer register.
Subsequently, the parallel byte is transferred to the MPU
when requested.

The transmitter accepts parallel data from the MPU and


converts into serial data. It has two register: a buffer register
to hold eight bits and an o/p register to convert eight bits
Downloaded from www.jayaram.com.np 54 Downloaded from www.jayaram.com.np
DMA
Introduction:
 Direct Memory Access (DMA) is a method of allowing data to be moved from one location to another in a
computer without intervention from the central processor (CPU).
 It is also a fast way of transferring data within (and sometimes between) computer.
 The DMA I/O technique provides direct access to the memory while the microprocessor is temporarily
disabled.
 The DMA controller temporarily borrows the address bus, data bus and control bus from the
microprocessor and transfers the data directly from the external devices to a series of memory locations
(and vice versa).

Basic DMA Operation:


 Two control signals are used to request and acknowledge a direct memory access (DMA) transfer in the
microprocessor-based system.
 The HOLD signal as an input(to the processor) is used to request a DMA action.
 The HLDA signal as an output that acknowledges the DMA action.
 When the processor recognizes the hold, it stops its execution and enters hold cycles.
 HOLD input has higher priority than INTR or NMI.
 The only microprocessor pin that has a higher priority than a HOLD is the RESET pin.
 HLDA becomes active to indicate that the processor has placed its buses at high- impedance state.

Basic DMA Definitions:


 Direct memory accesses normally occur between an I/O device and memory without the use of the
microprocessor.
 A DMA read transfers data from the memory to the I/O device.
 A DMA write transfers data from an I/O device to memory.
 The system contains separate memory and I/O control signals.
 Hence the Memory & the I/O are controlled simultaneously
 The DMA controller provides memory with its address, and the controller signal selects the I/O device
during the transfer.
 Data transfer speed is determined by speed of the memory device or a DMA controller.
 In many cases, the DMA controller slows the speed of the system when transfers occur.
 The serial PCI (Peripheral Component Interface) Express bus transfers data at rates exceeding DMA
transfers.
 This in modern systems has made DMA is less important.

The 8237 DMA Controller


 The 8237 supplies memory & I/O with control signals and memory address information during the DMA
transfer.
 It is actually a special-purpose microprocessor whose job is high-speed data transfer between memory and
I/O
1. CPU having the control over the bus:
2. When DMA operates:
 8237 is not a discrete component in modern microprocessor-based systems.
 It appears within many system controller chip sets
 8237 is a four-channel device compatible with 8086/8088, adequate for small systems.
 Expandable to any number of DMA channel inputs
 8237 is capable of DMA transfers at rates up to 1.6MB per second.
 Each channel is capable of addressing a10 full

fig:Block Diagram of 8237


Modes of 8237 DMA Controller
Single mode
In single mode only one byte is transferred per request. For every transfer, the counting register is decremented and
address is incremented or decremented depending on programming. When the counting register reaches zero, the terminal
count TC signal is sent to the card.
The DMA request DREQ must be raised by the card and held active until it is acknowledged by the DMA
acknowledge DACK.

Block transfer mode


The transfer is activated by the DREQ which can be deactivated once acknowledged by DACK. The transfer continues
until end of process EOP(either internal or external) is activated which will trigger terminal count TC to the card. Auto-
initialization may be programmed in this mode.

Demand transfer mode


The transfer is activated by DREQ and acknowledged by DACK and continues until either TC,
external EOP or DREQ goes inactive. Only TC or external EOP may activate auto-initialization if this is programmed.

You might also like