5 Sem Microprocessor Notes
5 Sem Microprocessor Notes
STUDY MATERIAL
BCA
III YEAR/V SEMESTER
MICRopRoCESSoR
AnD
ASSEMBLY LAngUAgE
(BCA505T)
pREpARED BY
g.gnAnESWARI
ASST. pRofESSoR
nHC, MARATHALLI.
UNIT - I
Components of MuP:
1:Register and accumulator.
2:ALU.
3:Instruction decoder and machine cycle encoder.
4:Address buffer.
5:Address/data buffer.
6:Inc/Dec latch.
7:Interrupt control.
8:Serial i/o like SOD,SID.
9:Timing and Control circuit.
ALP
• Assembly language programming: Microprocessors are programmed in ALP.
It is a middle level language which consists of mnemonics.
Eg.
ADD A,B
MOV C,A
Instruction set:
It uses various combinations such as 1 byte, 2 byte and 3 byte.
Eg. Increment Accumulator, Add B
1 byte instruction:
Characteristics of a Micropocessor:
Instruction set: The set of instructions that the microprocessor can execute.
(248 )
clock speed : Given in megahertz (MHz), the clock speed determines how
many instructions per second the processor can execute. (3 MHz)
Accumulator:
• The accumulator is an 8-bit register
• It is a part of the arithmetic/logic unit(ALU).
• This register is used to store 8-bit data which is used to perform arithmetic &
logical operation.
• The result of an operation is stored in the accumulator.
• The accumulator is also identified as register A.
Registers
• The 8085 simulator has six general-purpose registers to store 8-bit data;
The programmer can use these registers to store or copy data into the registers by
using data copy instructions.
• Out of these six registers, four 8-bit registers are Scratch pad registers which
are accessible to the programmer and hence can be used to store data during
a program execution.
• And the two registers H and L are similar to that of scratch pad register but
they are utilized in Indirect addressing mode. In this mode, the memory
location i.e. the address is specified by the contents of the registers.
• The temporary registers W and Z are intended for internal use of the processor
and it cannot be used by the programmer.
• The function of the program counter is to point to the memory address from
which the next instruction is to be fetched.
• The stack pointer is also a 16-bit register used as a memory pointer. It points
to a memory location in R/W memory, called the stack.
• The return address of the PC from where the program control was transferred
to the subroutine this return address is kept in a special area called stack.
• Stack pointer is useful when interrupt occur i.e. before execution of call
instruction, address of next instruction is copied into stack pointer.
They are subdivided into maskable (RST, INTR ) and non maskable (TRAP)
interrupts
Maskable: When the interrupt is received the processor saves the contents of
the PC into stack and branches to the respective address.
• INTR: Known as hardware interrupt and has Lowest priority.
• INTA: Interrupt Acknowledge signal. It is a active low signal.
S1 S0 Operation
0 0 Fetch
operation
0 1 Write
operation
1 0 Read
Operation
1 1 Halt
operation
• Clock: It generates clock frequency of 3 mHz and will be applied to other digital
IC’s which requires same clock pulse.
• SID (Serial Input Data line)- The data on this line is loaded into accumulator bit
7 whenever a RIM(read interrupt mask) instruction is executed.
• SOD (Serial Output Data line)- The SIM (set interrupt mask) instruction loads
the value of bit 7 of the accumulator into SOD.
• ALE (Address Latch Enable): ALE=1, bus functions as address bus, ALE=0,
bus functions as data bus.
• HOLD: It indicates that another master is requesting the use of address and
data buses. CPU will relinquish the bus soon after current bus transfer.
• HLDA (Hold Acknowledge): Indicates that the CPU has received the HOLD
request and that it will relinquish the bus in the next clock cycle.
• AD7 – AD0 : bidirectional and dual purpose (address and data placed once at
a time). This technique of sharing of data and address on the bus is known as
multiplexing.
• The memory write machine cycle is executed by the processor to write a data
byte in a memory location.
• The processor takes,3T states to execute this machine cycle..
• The I/O Read cycle is executed by the processor to read a data byte from I/O
port or from the peripheral, which is I/O, mapped in the system.
• The processor takes 3T states to execute this machine cycle.
• The IN instruction uses this machine cycle during the execution
• The I/O write machine cycle is executed by the processor to write a data byte in
the I/O port or to a peripheral, which is I/O, mapped in the system.
• The processor takes, 3T states to execute this machine cycle
UNIT – II
Programming 8085:
The instructions MOV B, A or MVI A, 82H are to copy data from a source into a
destination. In these instructions the source can be a register, an input port, or an
8-bit number (00H to FFH). Similarly, a destination can be a register or an output
port. The sources and destination are operands. The various formats for specifying
operands are called the ADDRESSING MODES. For 8085, they are:
1. Immediate addressing.
2. Register addressing.
3. Direct addressing.
4. Indirect addressing.
Immediate addressing
Data is present in the instruction. Load the immediate data to the destination
provided.
Example: MVI R,data
Register addressing
Data is provided through the registers.
Example: MOV Rd, Rs
Direct addressing
Used to accept data from outside devices to store in the accumulator or send the data
stored in the accumulator to the outside device. Accept the data from the port 00H
and store them into the accumulator or Send the data from the accumulator to the
port 01H.
Example: IN 00H or OUT 01H
Indirect Addressing
This means that the Effective Address is calculated by the processor. And the
contents of the address (and the one following) is used to form a second address. The
second address is where the data is stored. Note that this requires several memory
accesses; two accesses to retrieve the 16-bit address and a further access (or
accesses) to retrieve the data which is to be loaded into the register.
These instructions are 1-byte instructions performing three different tasks. In the
first instruction, both operand registers are specified. In the second instruction, the
operand B is specified and the accumulator is assumed. Similarly, in the third
instruction, the accumulator is assumed to be the implicit operand. These
instructions are stored in 8-bit binary format in memory; each requires one memory
location.
MOV rd, rs
rd <-- rs copies contents of rs into rd.
Coded as 01 ddd sss where ddd is a code for one of the 7 general registers which is
the destination of the data, sss is the code of the source register.
Example: MOV A,B
Coded as 01111000 = 78H = 170 octal (octal was used extensively in instruction
design of such processors).
ADD r
A <-- A + r
Two-Byte Instructions
In a two-byte instruction, the first byte specifies the operation code and the second
byte specifies the operand. Source operand is a data byte immediately following the
opcode. For example:
Assume that the data byte is 32H. The assembly language instruction is written as
Three-Byte Instructions
In a three-byte instruction, the first byte specifies the opcode, and the following two
bytes specify the 16-bit address. Note that the second byte is the low-order address
and the third byte is the high-order address.
opcode + data byte + data byte
For example:
• DataTransfer Instruction
• Arithmetic Instructions
• Logical Instructions
• Branching Instructions
• Control Instructions
• This instruction copies thecontents of the source register into the destination
register.
• Thecontents of the source registerare not altered.
• If one of the operands is a memory location, its location is specified by the
contents of the HL registers.
•
• Opcode • Operand • Description
E xa m p le: LD A 2 0 3 4 H
E xa m p le: LD AX B
E xa m p le: LH LD 2 0 4 0 H
E xa m p le: S TA 2 5 0 0 H
E xa m p le: S TAX B
Th ec on t e n t s of r egis t er p a ir a r e c op ie d on t o s t a c k .
S P is d ec r em en t ed a n d t h ec on t en t s o f h igh-order registers (B, D, H, A) are copied
into stack.
S P is a ga in decremented and the contents of low-order registers (C, E, L, Flags)
are copied into stack.
E xa m p le: PU S H B
E xa m p le: PO P H
OUT 8-bitport address Copydata from accumulator toa port with 8-bit
address
Th ec on t e n t s of a cc u m u la t or a r e c op ie d in t o t h e I/ O p or t .
E xa m p le: O U T 7 8 H
Arithmetic Instructions:
Addition
An y 8-bit number, or the contents of register, or the contents of memory location
can be added to the contents of accumulator.
Th e r es u lt (s u m ) is s t or ed in t h e a c cu m u la t or .
No t w o other 8-bit registers can be added directly.
Subtraction
An y 8-bit number, or the contents of register, or the contents of memory location
can be subtracted from the contents of accumulator.
Th e r es u lt is s t or ed in t h e a c c u m u la t or .
S u b t r a c t ion is p er for m ed in 2 ’s c om p lem e n t for m .
If t h e r es u lt is negative, it is stored in 2’s complement form.
No t w o other 8-bit registers can be subtracted directly.
Increment / Decrement
E xa m p le: AD D B or AD D M
Th e contents of register or memory and Carry Flag (CY) are added to the
contents of accumulator.
Th e r es u lt is s t or ed in a c c u m u la t or .
If t h e operand is memory location, its address is specified by H-L pair.
All fla gs a r e m od ified t o r eflec t t h e r es u lt of the addition.
E xa m p le: AD C B or ADC M
Opcode Operand Description
E xa m p le: AD I 4 5 H
Th e 8-bit data and the Carry Flag (CY) are added to the contents of accumulator.
Th e r es u lt is s t or ed in a c c u m u la t or .
All fla gs a r e m od ified t o r eflec t t h e r es u lt of t h e a d d it ion .
E xa m p le: AC I 4 5 H
Th e 1 6-bit contents of the registerpairare added to the contents of H-L pair.
Th e r es u lt is s t or ed in H-L pair.
If t h e r es u lt is la r ger t h a n 1 6 b it s , t h en C Y is s et .
Noot h er fla gs a r e c h a n ged .
E xa m p le: D AD B
Th e contents of the registeror memory location are subtracted from the
contentsof the accumulator.
Th e r es u lt is s t or ed in a c c u m u la t or .
If t h e operand is memory location, its address is specified by H-L pair.
All fla gs a r e m od ified t o r eflec t t h e r es ult of subtraction.
E xa m p le: S U B B or S U B M
E xa m p le: S B B B or S B B M
E xa m p le: S U I 4 5 H
Th e 8-bit data and the Borrow Flag (i.e. CY) is subtracted from the contents of
theaccumulator.
Th e r es u lt is s t or ed in a c c u m u la t or .
All fla gs a r e m od ified t o r eflec t t h e r es u lt of subtraction.
E xa m p le: S B I 4 5 H
Th ec on t e n t s of r egis t er p a ir a r e in c r e m en t ed b y 1 .
Th e r es u lt is s t or ed in t h e s a m e p la c e.
E xa m p le: INX H
E xa m p le: D C R B or D C R M
DCX R Decrementregisterpair by 1
Th ec on t e n t s of r egis t er p a ir a r e d ec r e m en t ed b y 1 .
Th e r es u lt is s t or ed in t h e s a m e p la c e.
E xa m p le: D C X H
Logical Instructions
Rotate
Compare
Complement
Th ec on t en t s of a cc u m u la t or c a n becomplemented.
E a c h 0 is r ep la c ed b y 1 a n d ea c h 1 is r ep la c ed b y 0 .
Logical Instructions
E xa m p le: C MP B or C MP M
Th ec on t en t s of t h e a c c u m u la t or a r e logic a lly O R ed w it h t h ec on t en t s of t h e
registeror memory.
Th e result is placed in the accumulator.
If t h eop er a n d is a m em or y loc a t ion , it s a d d r es s is s p ec ified b y t h ec on t en t s of
H-L pair.
S , Z, P a r e m od ified t o r eflec t t h e r e s u lt .
C Ya n d AC a r e r es et .
E xa m p le: O RA B or O RA M.
Th e contents of the accumulator are XORed with the contents of the register or
memory.
Th e r es u lt is p la c ed in t h e a c c u m u la t or .
If t h eop er a n d is a m em or y loc a t ion , its address is specified by the contentsof H-L
pair.
S , Z, P a r e m od ified t o r eflec t t h e r es u lt of t h e operation. C Ya n d AC a r
E xa m p le: XRA B or XRA M.
E a c h b in a r y b it of t h ea c c u m u la t or is r ot a t ed r igh t b y on e p os it ion .
B it D 0 is p la c ed in t h e p os it ion of D 7 a s w ell a s in t h e C a r r y fla g.
C Y is m od ified a c c or d in g t o b it D 0 . S , Z, P, AC a r e n ot a ffec t ed . E xa m p le:
RRC.
E a c h b in a r y b it of t h ea c c u m u la t or is r ot a t ed left b y on e p os it ion t h r ou gh t h e
Carry flag.
B it D 7 is p la c ed in t h e C a r r y fla g, a n d t h e C a r r y fla g is p la c ed in t h e lea s t
significant position D0.
C Y is m od ified a c c or d in g t o b it D 7 .
S , Z, P, AC a r e n ot a ffec t ed .
E xa m p le: R AL.
Th ec on t e n t s of t h ea c c u m u la t or a r e c om p lem en t ed .
No fla gs a r e a ffec t ed .
E xa m p le: C MA.
Th e C a r r y fla g is s et t o 1 .
Noot h er fla gs a r e a ffec t ed .
E xa m p le: S TC .
Branching Instructions
Jx 16-bitaddress Jumpconditionally
E xa m p le: J Z 2 0 3 4 H .
Jump Conditionally
JC Jump if Carry CY = 1
E xa m p le: C ALL 2 0 3 4 H .
Call Conditionally
CC Call if Carry CY = 1
E xa m p le: R E T.
Return Conditionally
RC Return if Carry CY = 1
RNC Return if No Carry CY = 0
RP Return if Positive S=0
RM Return if Minus S=1
RZ Return if Zero Z=1
RNZ Return if No Zero Z=0
RPE Return if Parity Even P=1
RPO Return if Parity Odd P=0
E xa m p le: R S T 3 .
RST 0 0000 H
RST 1 0008 H
RST 2 0010 H
RST 3 0018 H
RST 4 0020 H
RST 5 0028 H
RST 6 0030 H
RST 7 0038 H
Control Instructions
E xa m p le: NO P
E xa m p le: H LT
Th e in t er r u p t en a b le flip-flop is reset and all the interruptsexcept the TRAP are
disabled.
No fla gs a r e a ffec t ed .
E xa m p le: D I
E xa m p le: E I
RIM Instruction
Th is is a m u lt ip u r p os e in s t r u c t ion u s ed t o r ea d t h e s t a t u s of in t er r u p t s 7 .5 , 6 .5 ,
5.5 and read serial data input bit.
Th e in s t r u c t ion loa d s eigh t b it s in t h ea c c u m u la t or w it h t h e follow in g
interpretations.
E xa m p le: R IM
SIM Instruction
E xa m p le: S IM
Unit - III
Programming techniques:
Counters
MVI C, 15 H
LOOP DCR C
JNZ LOOP
• Using a single register, one can repeat a loop for a maximum count of 255
times.
• It is possible to increase this count by using a register pair for the loop
counter instead of the single register.
• A minor problem arises in how to test for the final count since DCX and
INX do not modify the flags.
The following is an example of a loop set up with a register pair as the loop
counter.
LXI B, 1000 H
LOOP DCX B
MOV A, C
JNZ LOOP
Delays
Disadvantage,
-the time of the processor is wasted.
-alternate solution is to use a dedicated timer like 8253/54 to product time
delays.
A0 00 21
A0 01 45
A0 02 F0
Stacks & Subroutines
STACK
o The stack is an area of memory identified by the programmer for temporary
storage of information.
o Given that the stack grows backwards into memory, it is customary to place
the bottom of the stack at the end of memory to keep it as far away from user
programs as possible.
o In the 8085, the stack is defined by setting the SP (Stack Pointer) register.
LXI SP, FFFFH
o This sets the Stack Pointer to location FFFFH (end of memory for the 8085).
o Information is saved on the stack by PUSH
o The 8085 provides two instructions: PUSH and POP for storing information on
the stack and retrieving it back.
o Decrement SP
o Decrement SP
o Increment SP
o Increment SP
o The information is retrieved from the top of the the stack and then the
pointer is incremented.
SUBROUTINES
o A subroutine is a group of instructions that will be used repeatedly in different
locations of the program.
o Rather than repeat the same instructions several times, they can be
grouped into a subroutine that is called from the different locations.
o In Assembly language, a subroutine can exist anywhere in the code.
o However, it is customary to place subroutines separately from the main
program.
o The 8085 has two instructions for dealing with subroutines.
o The RTE instruction is used to return the execution to the calling routine.
o 3-byte instruction.
o Load the program counter with the 16-bit address supplied with the
CALL instruction.
o 1-byte instruction
o Retrieve the return address from the top of the stack and increments
stack pointer register by two.
Program Ececution:
CALL Execution
● Instruction requires five machine cycles and eighteen T-states:
RET Execution
● Program execution sequence is transferred to the memory location
2043H
o The data is stored in one of the registers by the calling program and the
subroutine uses the value from the register.
o The calling program stores the data in the memory location and the
subroutine retrieves the data from the location and uses it.
RESTART INSTRUCTIONS
Unit -IV
Interrupts :
8085 vectored interrupts , Restart as Software instructions, additional I/O concepts
and processes.
What is an Interface?
Memory Interface
The memory is made up of semiconductor material used to store the programs
and data.
Primary Memory
• RAM and ROM are examples of this type of memory.
• Microprocessor uses it in storing a program temporarily (commonly called
loading) and executing a program.
• Hence the speed of this type of memory should be fast.
Secondary Memory
• These are used for bulk storage of data and information.
• The main examples include Floppy, Hard Disk, CD-ROM, Magnetic Tape etc.
• Slower and Sequential Access.
• Non-volatile.
Memory Chip
• Memory 216 words
• 8 bits per word
• 16 address lines
• 8 data input lines
• 8 output lines
• Example Block Diagram
8085 Interrupt
• Interrupt signals are send by an external device to the processor.
• It used to request to perform a particular task.
• Interrupts are used for data transfer between the peripheral and the
microprocessor.
Whenever there is an Interrupt, The content of the PC and the status are saved in the
stack.
• The pointer jumps to the subroutine program called ISS(Interrupt service
subroutine)
• Which includes memory and /I/O mapped commands such as LDA, STA, IN,
OUT.
• The interrupt is controlled by the Interrupt Enable Flip flop which is set and
reset using instructions such as EI –enable interrupt and DI disable
interrupt.
• If the flipflop is enabled then interrupt is sent by the external device to the MP.
INTR signal goes high.
• The microprocessor completes the current instruction execution, disables the
interrupt so that no interrupt is accepted until it is enabled again.
• The INTR signal inserts a restart (RST) instruction through external hardware.
• The RST instruction transfers the program control to a specified memory
location called the ISS (Interrupt service subroutine).
• The address of the next instruction will be stored in the stack.
• Once the MP encounters RET it will return back to the main program.
• Hardware Interrupts: TRAP,RST 7.5, RST 6.5, RST 5.5 and INTR.
• Software Interrupts: RST 0,RST 1, RST2, RST 3, RST 4, RST 5, RST 6 and
RST 7.
Software interrupts
Restart Equivalent to
Instruction
Hardware interrupts
Hardware interrupts
• Non Vectored inputs : When the device interrupts through INTR, the
interrupted device should provide the address of Interrupt service Routine
(ISR) after receiving interrupt acknowledge signal. (INTA)
INTR Yes No
TRAP No Yes
Interrupt instructions
SIM Instruction
SIM Instruction
Pending Interrupts
• Since the 8085 has five interrupt lines, interrupts may remain pending.
• Using the RIM instruction, it is possible to can read the status of the
interrupt lines and find if there are any pending interrupts.
• Bits 0-2 show the current setting of the mask for each of RST 7.5, RST 6.5 and
RST 5.5 .
• Bit 3 shows whether the maskable interrupt process is enabled or not.
• It can be used by a program to determine whether or not interrupts are
enabled.
• Bits 4-6 show whether or not there are pending interrupts on RST 7.5, RST
6.5, and RST 5.5 .
• Bit 7 is used for Serial Data Input.
• The RIM instruction reads the value of the SID pin on the microprocessor and
returns it in this bit.
Restart Sequence
UNIT-V
8255 A PROGRAMMABLE PERIPHERAL INTERFACE:
The 8255A is a general purpose programmable I/O device designed for use with
Intel Microprocessors. It consists of three 8-bit bidirectional I/O ports (24 I/O lines)
that can be configured to meet different system I/O needs. The three ports are
PORTA, PORTB & PORTC. PortA contains one 8-bit output latch/buffer and one
8-bit input buffer. PortB is same as PORTA or PORTB.However, PORTC can be split
into two parts PORTC lower(PC0-PC3) and PORTC upper (PC7-PC4) by the control
word. The three ports are divided intwo groups GroupA (PORTA and upper PORTC)
GroupB (PORTB and lower PORTC). The two groups can be programmed in three
different modes. In the first mode (mode0), each group may be programmed in
either input mode or output mode (PORTA, PORTB, PORT C lower, PORTC upper).
In mode1, the second’s mode, each group may be programmed to have 8-lines of
input or output (PORT A or PORT B) of the remaining 4-lines (PORT C lower or
PORT C upper) 3-lines are used for handshaking and interrupt control signals. The
third mode of operation (mode2) is a bidirectional bus mode which uses 8-line
(PORT A only for a bidirectional bus and five lines (PORT C upper 4 lines and
borrowing one from other group) for handshaking. The 8255 is contained in a
40-pin package, whose pin out is given below:
Functional Description:
It is a tri-state 8-bit buffer used to interface the chip to the system databus. Data
is transmitted or received by the buffer upon execution of input or output
instructions by the CPU. Control words and status information are also
transferred through the databus buffer. The data lines are connected to BDB of
microprocessor.
The function of this block is to control the internal operation of the device and to
control the transfer of data and controlor status words. It accepts inputs from the
CPU address and control buses and inturn issues command to both the control
groups.
ChipSelect: A low on this input selects the chip and enables the communication
between the 8255A & the CPU. It is connected to the output of address decode
circuitry to select the device when it (Read). A low on this input enables the 8255
to send the data or status information to the CPU on the databus.
Write: A low on this input pin enables the CPU to write data or control words into
the 8255A.
A1,A0 port select : These input signals, in conjunction with the and inputs,
control the selection of one of the three ports or the control word registers. They
are normally connected to the least significant bits of the address bus (A0andA1).
Following Table gives the basic operation,
All other states put data bus into tri-state/ illegal condition.
RESET: A high on this input pin clears the control register and all ports (A, B & C)
are initialized to input mode. This is connected to RESET OUT of 8255. This is
done to prevent destruction of circuitry connected to port lines. If port lines are
initialized as output after a power up or reset, the port might try to output into the
output of a device connected to same inputs might destroy one or both of them.
PORTs A, B and C: The 8255A contains three 8-bit ports (A, B and C). All can be
configured in a variety of functional characteristic by the system software.
PORT A: One 8-bit data output latch/buffer and one 8-bit data input latch.
PORT B: One 8-bit data output latch/buffer and one 8-bit data input buffer.
PORTC: One 8-bit data output latch/buffer and one 8-bit data input buffer (no
latch for input). This port can be divided into two 4-bit ports under the mode
control. Each 4-bit port contains a 4-bit latch and it can be used for the control
signal outputs and status signals inputs in conjunction with ports A and B.
Control Group A – Port A & Port C upper Control Group B – Port B & Port C lower
The control word register can only be written into No read operation if the control
word register is allowed.
Operation Description: Mode selection: There are three basic modes of operation
that can be selected by the system software.
When the reset input goes HIGH all poets are set to mode ’0’ as input which
means all 24 lines are in high impedance state and can be used as normal input.
After the reset is removed the 8255 A remains in the input mode with no
additional initialization. During the execution of the program any of the other
modes may be selected using a single output instruction.
The modes for PORT A & PORT B can be separately defined, while PORT C is
divided into two portions as required by the PORT A and PORT B definitions. The
ports are thus divided into two groups Group A & Group B. All the output
register, including the status flip-flop will be reset whenever the mode is changed.
Modes of the two group may be combined for any desired I/O operation e.g.
Group A in mode‘1’and group B in mode‘0’.
Mode Definition
The basic mode definitions with bus interface and the mode definition format are
given in fig 5.3 & 5.4
Mode0
Mode 1&2
1) Handle eight interrupt inputs. This is equivalent to providing eight interrupt pins
on the processor in place of one INTR/INT pin.
2) Vector an interrupt request anywhere in the memory map. However, all the eight
interrupt are spaced at the interval of either four or eight location. This eliminates the
major drawback, 8085 interrupt, in which all interrupts are vectored to memory
location on page 00 H.
processor. It also induces additional features such as level triggered mode, Buffered
mode and automatic end of interrupt mode. The pin diagram and interval block
diagram is shown below:
Chipselect: To access this chip, CS’ is made low. A LOW on this pin enables RD’&WR’
communication between the C PU and the 8259 A. This pin is connected to address
bus through the decoder logic circuits. INTA functions are independent of CS’
WR’:.Alowonthispin.WhenCS’islowenablesthe8259AtoacceptcommandwordsfromCP
U.
RD’: A low on this pin when CS’ is low enables these 8259 A to release status on to the
databus for the CPU. The status includes the contents of IMR, ISR or TRR register or
a priority level.
D7-D0: Bidirectional databus control status and interrupt in a this bus. This bus is
connected to BDB of 8085.
CAS0-CAS2: Cascade lines: The CAS lines form a private 8259 A bus to control a
multiple 8259 A structure ie to identify a particular slave device. These pins are
outputs of a master 8259 A and inputs for a slave 8259 A.
Salve program / enable buffer: This is a dual function pin. It is used as an input to
determine whether the 8259 A is to a master (SP/EB=1) or as a slave (SP/EB=0). It is
also used as an output to disable the data bus transceivers when data are being
transferred from the 8259A to the CPU. When In buffered mode, it can be used as an
output and when not in the buffered mode it is used as an input.
INT: This pin goes high whenever a valid interrupt request is asserted. It is used to
interrupt the CPU, thus it is connected to the CPU’s interrupt pin (INTR).
Interrupt Acknowledge: This pin is used to enable 8259 A interrupt vector data on the
A0:A0addressline:This pin acts in conjunction with the, RD’, WR’ & CS’ pins. It is
used by the 8259 A to send various command words from the CPU and to read the
status. If is connected to the CPU A0 address line. Two addresses must be reserved in
the I/O addresss pace for each 8259 in the system.
Functional Description: The 8259 A has eight interrupt request inputs, TR2IR0. The
8259 A uses its INT output to interrupt the 8085 A via INTR pin. The 8259 A receives
interrupt acknowledge pulses from the at its input. Vector address used by the 8085
A to transfer control to the service subroutine of the interrupting device, is provided
by the 8259 A on th e databus. The 8259 A is a programmable device that must be
initialized by command words sent by the. After initialization the 8259 A mode of
operation can be changed by operation command words from the microprocessor.
Read/Write & control logic: The function of this block is to accept OUTPUT
commands from the CPU. It contains the initialization command word (ICW) register
and operation command
Word (OCW) register which store the various control formats for device operation.
This function block also allows the status of 8159 A to be transferred to the databus.
Interrupt request register(IRR): IRR stores all the interrupt inputs that are requesting
service. Basically, it keeps track of which interrupt inputs are asking for service. If an
interrupt input is unmasked, and has an interrupt signal on it, then the
corresponding bit in the IRR will be set.
Interrupt mask register (IMR): The IMR is used to disable (Mask) or enable (Unmask)
individual interrupt inputs. Each bit in this register corresponds to the interrupt
input with the same number.The IMR operation on the IRR. Masking of higher
priority input will not affect the interrupt request lines of lower priority.To unmask
any interrupt the corresponding bit is set‘0’.
Inservice register (ISR): The inservice registers keeps tracks of which interrupt
inputs are currently being serviced. For each input that is currently being serviced
the corresponding bit will be set in the inservice register.Each of these 3-reg can be
read as status reg.
Priority Resolver: This logic block determines the priorities of the set in the IRR. The
highest priority is selected and strobed into the corresponding bit of the ISR during
INTA’ pulse.
Cascade buffer/comparator: This function blocks stores and compare the IDS of all
8259 A’ s in the reg. The associated 3-I/O pins (CAS0-CAS2) are outputs when 8259
A is used a master. Master and are inputs when 8259 A is used as a slave. As a
master, the 8259 A sends the ID of the interrupting slave device onto the cas2-cas0.
The slave thus selected will send its pre-programmed subroutine address onto the
databus during the next one or two successive INTA’ pulses.
System memory and I/O bus with the CPU and has both bus master and slave
capability. Figure shows the DMA controller architecture and how the DMA controller
interacts with the CPU. In bus master mode, the DMA controller acquires the system
bus (address,data,and control lines) from the CPU to perform the DMA transfers.
Because the CPU releases the system bus for the duration of the transfer, the process
is sometimes referred to as cycle stealing.
In bus slave mode, the DMA controller is accessed by the CPU, which programs the
DMA controller's internal registers to setup DMA transfers. The internal registers
consist of source and destination address registers and transfer count registers for
each DMA channel, as well as control and status registers for initiating, monitoring,
DMA transfer
The second type of DMA transfer is referred to as a
dual-cycle,dual-address,flow-through,or fetch-and-deposit DMA transfer.
As these type of transfer involves two memory or I/O cycles. The data being
transferred is first read from the I/O device or memory into a temporary data register
internal to the DMA controller. The data is then written to the memory or I/O device
in the next cycle.Figure shows the fetch-and-deposit DMA transfer signal protocol.
Although inefficient because the DMA controller performs two cycles and thus retains
the systembus longer, this type of transfer is useful for interfacing devices with
different data bus sizes.
Fetch-and-DepositDMATransfer8237DMAcontrollerIC:
GND Ground
CLK: CLOCK INPUT: The Clock Input is used to generate the timing signals which
CS:CHIPSELECT: Chip Select is an active low input used to enable the controller on
to the databus for CPU communications.
READY:This signal can be used to extend the memory read and write pulses from the
82C37A to accommodates low memories or I/O devices.
IOR:READ:I/O Read is a bidirectional active low three-state line. In the Idle cycle, it is
an input control signal used by the CPU to read the control registers. In the Active
cycle,it is an output control signal used by the 82C37A to access data from the
peripheral during a DMA Write transfer.
IOW:WRITE: I/O Write is a bidirectional active low three-stateline. In the Idle cycle, it
is an input control signal used by the CPU to load information into the82C37A.In the
Active cycle,it is an output control signal used by the 82C37A to load data to the
peripheral during a DMA Read transfer.
EOP:ENDOFPROCESS:End of Process(EOP) is an active low bidirectional signal.
Information concerning the completion of DMA services is available at the
bidirectional EOP pin. The 82C37A allows an external signal to terminate an active
DMA service by pulling the EOP pin low. A pulse is generated by the 82C37A when
terminal count(TC) for any channel is reached, except for channel0 in
memory-to-memory mode. During memory-to-memory Transfers, EOP will be output
when the TC for channel 1 occurs. The EOP pin is driven by an open drain transistor
on-chip,and requires an external pull-up resistor toVCC.When an EOP pulse occurs,
whether internally or externally generated, the82C37A will terminate the service, and
if auto-initialize is enabled, the base registers will be written to the current registers of
that channel.The mask bit and TC bit in the status word will be set for the currently
active channel by EOP unless the channel is programmed for auto initialize. In that
case,the mask bit remains clear.
A4-A7:ADDRESS:The four most significant address lines are three-state outputs and
provide 4-bits of address.These lines are enabled onlyduring the DMA service.
LDA 1100
MOV B,A
LDA 1101
CMA
ADI 01
ADD B
STA 1102
HLT
;08
;02
;06
LDA 1100
LXI H,1101
ADD M
STA 1102
HLT
;1100 - 05
;1101 - 02
;1102 - 01
;1103 - 04
;1104 - 06
;1105 - 06
;1106 - 0
MVI C,00
LDA 1100
LXI H,1101
ADD M
JNC 16909
INR C
STA 1102
MOV A,C
STA 1103
HLT
;FA - 250
;EE - 238
;E8 - 232
;1 - 1
MVI D,00
MVI C,00
LXI H,1100
MOV A,M ;CONT
CPI 255;FF
JZ 0000 ;STOP
ADD D
JNC SKIP
INR C
MOV D,A ; SKIP
INX H
JMP CONT
MOV A,D ;STOP
STA 1200
MOV A,C
STA 1201
HLT
Ascending Order
LDA 1100
MOV B,A
DCR B
;LOOP3
LXI H,1100
MOV C,M
DCR C
INX H
;LOOP2
MOV A,M
INX H
CMP M
JC 16918 ;LOOP1
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
;LOOP1
DCR C
JNZ 16907 ;LOOP2
DCR B
JNZ 16901 ;LOOP3
HLT
ASCII TO BINARY(HEX)
LXI SP,65535;FFFFH
LXI H,1100
MOV A,M
CALL 16909;CONV
INX H
MOV M,A
HLT
;SUBROUTINE CONV
SUI 48 ; 30H CONV
CPI 10 ; 0AH :if A<10 c=1
RC ; return when carry
SUI 7 ;07H
RET
;1100 - 56 - 38H
;1101 - 8 - 8H
;1100 - 70 - 46H
;1101 - 15 - FH
MVI C,00
LHLD 1100
XCHG
LHLD 1102
MOV A,E
ADD L
DAA
JNC 16912; LOOP1
INR D
STA 1200 ; LOOP1
MOV A,D
ADD H
DAA
BCD to Binary
LDA 1100
MOV E,A
ANI 15 ;F0
RLC
RLC
RLC
RLC
MOV B,A
XRA A
MVI C,10
RET ;
DCR C
JNZ 0000 ;
MOV B,A
MOV A,E
ANI 15 ;0F
ADD B
STA 1101
HLT
;1100 - 68
;1101 - 44
Binary to BCD
MVI E,00
MOV D,E
LDA 1100
CPI 64 ; HUND
JC 0000; TEN
SUI 64 ;
INR E
JMP 0000 ;HUND
CPI 10 ; TEN
JC 0000 ;UNIT
SUI 10
INR D
Binary to ASCII
LDA 1200
CPI 10 ;0A
JC 16906 ;SKIP
ADI 07
ADI 48 ;30H ;SKIP
STA 1202
HLT
;1200 -10 - 0AH
;1202 - 65- 41H
Decending Order
LDA 1100
MOV B,A
DCR B
;LOOP3
LXI H,1101
MOV C,M
DCR C
INX H
;LOOP2
MOV A,M
INX H
CMP M
JNC 16918 ;LOOP1
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
;LOOP1
DCR C
JNZ 16907 ;LOOP2
DCR B
JNZ 16901 ;LOOP3
HLT
;DIVIDEND 4
LXI H,1100
MOV B,M
MVI C,00
;DIVISOR 8
INX H
MOV A,M
CMP B
JC 16913
SUB B
INR C
JMP 16904
;REMINDER 0
STA 1102
MOV A,C
;QUOTIENT 2
STA 1103
HLT
LHLD 1100
XCHG ;EXCHANGE HL AND DE
LHLD 1102
SHLD 1100
XCHG
SHLD 1102
HLT
Fibonacci series
MVI M,00
INX H
MVI M,01
INX H
MVI B,00
MVI C,01
MOV A,B ;LOOP
ADD C
MOV B,C
MOV C,A
MOV M,A
INX H
DCR D
JNZ 16915 ;LOOP
HLT
;1100 10
;1101 00
;1102 01
Largest of n numbers
LXI H,1100
MOV C,M
INX H
DCR C
MOV A,M
INX H
CMP M
JNC 16909
MOV A,M
DCR C
JNZ 16903
STA 1200
HLT
LXI H,1100
MOV B,M
MVI A,00
MOV C,A
INX H
ADD M
JNC 16909
INR C
DCR B
JNZ 16904
STA 1103
MOV A,C
STA 1104
HLT
LDA 1100
ORI 00
JZ 16910
JM 16915
JP 16920
MVI A,00
JMP 16922
MVI A,02
JMP 16922
MVI A,01
STA 1101
HLT
;ZERO 0
;NEGATIVE 251
;POSITIVE 8
;0-128 are positive numbers
Smallest of n numbers
LXI H,1100
MOV C,M
INX H
DCR C
MOV A,M
INX H
CMP M
JC 16909
MOV A,M
DCR C
JNZ 16903
STA 1200
HLT
MVI C,00
LHLD 1100
XCHG
LHLD 1102
MOV A,E
SUB L
STA 1104
MOV A,D
SBB H ; SUB WITH BORROW H WITH ACC
STA 1105
HLT
MVI C,00
LDA 1100
LXI H,1101
SUB M
JNC 16909
INR C
STA 1102
MOV A,C
STA 1103
HLT
;FA - 250
;FE - 254
;FC - 252
;1 - 1
MVI C,00
LDA 1100
LXI H,1101
SUB M
JNC 16909
INR C
STA 1102
MOV A,C
STA 1103
HLT
;
MVI C,10
LXI H,1100
LXI D, 1200
MOV A,M ; CONT
STAX D
INX H
INX D
DCR C
JNZ 16904 ;CONT
HLT