Computer Science Department: Majlis Arts and Science College, Puramannur
Computer Science Department: Majlis Arts and Science College, Puramannur
AND SCIENCE
COLLEGE,
PURAMANNUR
Computer
Science
Department
DBMS – MODULE-1
Example:
MVI B,00H ; INITIALIZE COUNTER
LOOP: DCR B ; COUNT=COUNT-1
MOV A,B ; MOVE COUNT TO ACC
OUT 01H ; DISPLAY IT AT PORT 01H
JNZ LOOP ; IF COUNT>0 REPEAT
6. What is stack?
The stack is a reserved area of the memory in RAM where we can store
temporary information. Interestingly, the stack is a shared resource as it can
be shared by the microprocessor and the programmer. The programmer
can use the stack to store data. And the microprocessor uses the stack to
execute subroutines.
The 8085 has a 16-bit register known as the ‘Stack Pointer.’ its function is
to hold the memory address of the stack. This control is given to the
programmer. The programmer can decide the starting address of the stack
by loading the address into the stack pointer register at the beginning of a
program.
The stack works on the principle of First In Last Out. The memory location
of the most recent data entry on the stack is known as the Stack Top.
7. Describe the procedure to implement a stack using instructions of 8085 with an illustrative
example.
The stack works on the principle of First In Last Out. The memory location of the most
recent data entry on the stack is known as the Stack Top.
Two operations used to control the movement of data into a stack and from a stack.
These two instructions are PUSH and POP.
PUSH – This is the instruction to write information on the stack. POP – This is the instruction
to read information from the stack.
There are two methods to add data to the stack: Direct method and Indirect method.using
either LXI or the SPHL instruction
In the direct method, the stack pointers address is loaded into the stack pointer register
directly. Using LXI instruction
In the indirect method, the stack pointers address is loaded into the stack pointer register via
another register pair. Using SPHL
In the direct method, the stack pointers address is loaded into the stack pointer register
directly.
LXI SP, 8000H
LXI H, 1234H
PUSH H
POP D
HLT
Explanation of the code
LXI SP, 8000H – The address of the stack pointer is set to 8000H by loading the number into
the stack pointer register. LXI H, 1234H – Next, we add a number to the HL pair. The most
significant two bits will enter the H register. The least significant two bits will enter the L
register.
PUSH H – The PUSH command will push the contents of the H register first to the stack.
Then the contents of the L register will be sent to the stack. So the new stack top will hold
34H.
POP D – The POP command will remove the contents of the stack and store them to the DE
register pair. The top of the stack clears first and enters the E register. The new top of the
stack is 12H now. This one clears last and enters the D register. The contents of the DE
register pair is now 1234H. HLT – HLT indicates that the program execution needs to stop.
In the indirect method, the stack pointers address is loaded into the stack pointer
register via another register pair.
LXI H, 8000H – The number that we wish to enter into the stack pointer, 8000H, is loaded
into the HL pair register.
SPHL – This is a special command that we can use to transfer data from HL pair to Stack
pointer (SP). Now, the contents of the HL pair are in the SP.
LXI H, 1234H – Next, we add a number to the HL pair. The most significant two bits will
enter the H register. The least significant two bits will enter the L register.
PUSH H – The PUSH command will push the contents of the H register first to the stack.
Then the contents of the L register will be sent to the stack. So the new stack top will hold
34H.
POP D – The POP command will remove the contents of the stack and store them to the DE
register pair. The top of the stack clears first and enters the E register. The new top of the
stack is 12H now. This one clears last and enters the D register. The contents of the DE
register pair is now 1234H.
HLT – HLT indicates that the program execution needs to stop.
Vectored Interrupts: Vectored Interrupts are those which have fixed vector address
(starting address of sub-routine) and after executing these, program control is
transferred to that address.
Vector Addresses are calculated by the formula 8 * TYPE.
INTERRUPT VECTOR ADDRESS
TRAP (RST 4.5) 24 H
RST 5.5 2C H
RST 6.5 34 H
RST 7.5 3C H
For Software interrupts vector addresses are given by:
INTERRUPT VECTOR ADDRESS
RST 0 00 H
RST 1 08 H
RST 2 10 H
RST 3 18 H
RST 4 20 H
RST 5 28 H
RST 6 30 H
RST 7 38 H
Non-Vectored Interrupts: are those in which the vector address is not predefined.
The interrupting device gives the address of the sub-routine for these interrupts. INTR
is the only non-vectored interrupt in an 8085 microprocessor.
Maskable Interrupts: are those which can be disabled or ignored by the
microprocessor. These interrupts are either edge-triggered or level-triggered, so they
can be disabled. INTR, RST 7.5, RST 6.5, RST 5.5 are maskable interrupts in 8085
microprocessor.
Non-Maskable Interrupts: are those which cannot be disabled or ignored by
microprocessor. TRAP is a non-maskable interrupt. It consists of both levels as well
as edge triggering and is used in critical power failure conditions.
TRAP It is a non-maskable interrupt, having the highest priority among all interrupts. By
default, it is enabled until it gets acknowledged. In case of failure, it executes as ISR and
sends the data to backup memory. This interrupt transfers the control to the location 0024H.
RST7.5 It is a maskable interrupt, having the second highest priority among all interrupts.
When this interrupt is executed, the processor saves the content of the PC register into the
stack and branches to 003CH address.
RST 6.5 It is a maskable interrupt, having the third highest priority among all interrupts.
When this interrupt is executed, the processor saves the content of the PC register into the
stack and branches to 0034H address.
RST 5.5 It is a maskable interrupt. When this interrupt is executed, the processor saves the
content of the PC register into the stack and branches to 002CH address.
INTR It is a maskable interrupt, having the lowest priority among all interrupts. It can be
disabled by resetting the microprocessor.
When INTR signal goes high, the following events can occur −
● The microprocessor checks the status of the INTR signal during the execution
of each instruction.
● When the INTR signal is high, then the microprocessor completes its current
instruction and sends an active low interrupt acknowledge signal.
● When instructions are received, then the microprocessor saves the address of
the next instruction on stack and executes the received instruction.
Enable Interrupt (EI) – The interrupt enable flip-flop is set and all interrupts are
enabled following the execution of the next instruction followed by EI. No flags are
affected. After a system reset, the interrupt enable flip-flop is reset, thus disabling the
interrupts. This instruction is necessary to enable the interrupts again (except TRAP).
Disable Interrupt (DI) – This instruction is used to reset the value of enable flip-flop
hence disabling all the interrupts. No flags are affected by this instruction.
Set Interrupt Mask (SIM) – It is used to implement the hardware interrupts (RST
7.5, RST 6.5, RST 5.5) by setting various bits to form masks or generate output data
via the Serial Output Data (SOD) line. First the required value is loaded in
accumulator then the SIM will take the bit pattern from it.
Read Interrupt Mask (RIM) – This instruction is used to read the status of the
hardware interrupts (RST 7.5, RST 6.5, RST 5.5) by loading into the A register a byte
which defines the condition of the mask bits for the interrupts. It also reads the
condition of SID (Serial Input Data) bit on the microprocessor.
The Intel 8255 is a programmable peripheral interface (PPI). It has two versions, namely the Intel
8255A and Intel 8255A-5. General descriptions for both are the same. There are some differences
in their electrical characteristics. Its main functions are to interface peripheral devices to the
microcomputer.
8255A
The 8255A is a general purpose programmable I/O device designed to transfer the
data from I/O to interrupt I/O under certain conditions as required. It can be used
with almost any microprocessor.
It consists of three 8-bit bidirectional I/O ports (24I/O lines) which can be configured
as per the requirement.
Ports of 8255A
8255A has three ports, i.e., PORT A, PORT B, and PORT C.
● Port A contains one 8-bit output latch/buffer and one 8-bit input buffer.
● Port B is similar to PORT A.
● Port C can be split into two parts, i.e. PORT C lower (PC0-PC3) and PORT C upper
(PC7-PC4) by the control word.
These three ports are further divided into two groups, i.e. Group A includes PORT A
and upper PORT C. Group B includes PORT B and lower PORT C. These two groups
can be programmed in three different modes, i.e. the first mode is named as mode 0,
the second mode is named as Mode 1 and the third mode is named as Mode 2.
Operating Modes
8255A has three different operating modes −
Mode 0 - Simple Input/output: The 8255 has two 8-bit ports (Port A and Port B) and two 4-bit
ports (Port Cupper and Port Clower). Each port can be programmed in either input mode or
output mode where outputs are latched and inputs are not latched. Ports do not have
interrupt capability.
Mode 1-Strobed Input/output: Mode 1 is strobed input/output mode of operation. The Port A
and Port B both are designed to operate in this mode of operation. When Port A and Port B are
programmed in Mode 1, six pins of Port C are used for their control.
Mode 2 -Bidirectional Port: Mode 2 is strobed bidirectional mode of operation. In this mode,
Port A can be configured as the bidirectional port and Port B either in Mode 0 or
Mode 1. Port A uses five signals from Port C as handshake signals for data transfer.
The remaining three signals from Port C can be used either as simple I/O or as a
handshake for port B.
The following figure shows the architecture of 8255A −
16. Describe the functional description of the pins in 8255A
Data Bus Buffer It is a tri-state 8-bit buffer, which is used to interface the
microprocessor to the system data bus. Data is transmitted or received by the buffer as per the
instructions by the CPU. Control words and status information is also transferred using this
bus.
CS A1 A0 Result
0 0 0 PORT A
0 0 1 PORT B
0 1 0 PORT C
0 1 1 Control Register
1 X X No Selection
WR It stands for write. This control signal enables the write operation. When this signal
goes low, the microprocessor writes into a selected I/O port or control register.
RESET This is an active high signal. It clears the control register and sets all ports in the
input mode.
RD It stands for Read. This control signal enables the Read operation. When the signal is
low, the microprocessor reads the data from the selected I/O port of the 8255.
A0 and A1 These input signals work with RD, WR, and one of the control signal.
Following is the table showing their various signals with their result.
A1 A0 RD WR CS Result
0 0 0 1 0 Input Operation
PORT A → Data Bus
Output Operation
0 0 1 0 0
Data Bus → PORT A
The two modes are selected on the basis of the value present at the D7 bit of the control
word register. When D7 = 1, 8255 operates in I/O mode, and when D7 = 0, it operates in the BSR
mode.
Bit set reset (BSR) mode – This mode is used to set or reset the bits of port C only,
and selected when the most significant bit (D7) in the control register is 0. Control
Register is as follows:
This mode affects only one bit of port C at a time because, as user set the bit, it remains
set until and unless user changes it. User needs to load the bit pattern in control register to
change the bit.
Input/output mode (I/O) – This mode is selected when the most significant bit (D7)
in the control register is 1. This is further divided into three modes:
The most significant bit (D7) is 1 for the I/O mode and 0 for the BSR mode.
D4 is used to tell whether port A is taking input or displaying the result. If it is 1 then it is
taking input otherwise displaying output.
D3 is used to tell whether port C higher bits are taking input or displaying the result. If it
is 1 then it is taking input otherwise displaying output.
D1 is used to tell whether port B is taking input or displaying the result. If it is 1 then it is
taking input otherwise displaying output.
D0 is used to tell whether port C lower bits are taking input or displaying the result. If it is
1 then it is taking input otherwise displaying output.
When 8255 microprocessor is reset, it will clear the control word register contents, setting
all the ports to input mode.
In the above figure, there are three counters, a data bus buffer, Read/Write control logic, and
a control register.
It has 3 counters each with two inputs (Clock and Gate) and one output. Gate is used to
enable or disable counting. When any value of count is loaded and the value of gate is set(1),
after every step the value of count is decremented by 1 until it becomes zero.
It is a tri-state, bi-directional, 8-bit buffer, which is used to interface the 8253/54 to the
system data bus. It has three basic functions −
Read/Write Logic
It includes 5 signals, i.e. RD, WR, CS, and the address lines A0 & A1. In the peripheral I/O
mode, the RD and WR signals are connected to IOR and IOW, respectively. In the memory
mapped I/O mode, these are connected to MEMR and MEMW.
Address lines A0 & A1 of the CPU are connected to lines A0 and A1 of the 8253/54, and CS is
tied to a decoded address. The control word register and counters are selected according to
the signals on lines A 0 & A 1.
Depending upon the value of CS, A1 and A0 we can determine addresses of selected
counters.
CS A1 A0 SELECTION
0 0 0 C0
0 0 1 C1
0 1 0 C2
0 1 1 Control Register
This register is accessed when lines A0 & A1 are at logic 1. It is used to write a command
word, which specifies the counter to be used, its mode, and either a read or write operation.
Following table shows the result for various control inputs.
A1 A0 RD WR CS Result
0 0 1 0 0 Write Counter 0
0 1 1 0 0 Write Counter 1
1 0 1 0 0 Write Counter 2
0 0 0 1 0 Read Counter 0
0 1 0 1 0 Read Counter 1
1 0 0 1 0 Read Counter 2
1 1 0 1 0 No operation
X X 1 1 0 No operation
X X X X 1 No operation
Applications –To generate accurate time delay,As an event counter,Square wave generator,
Rate generato rand Digital one shot
● 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.
The internal registers used in the 8237 for data transfer are as follows:
● Base address register: To store the initial address from where data transfer will take place
● Base word count register: To store the number of transfers to be performed
● Current address register: To store the current address from where data is being transferred
● Current word count register: To store the number of transfers remaining to be performed
● Temporary address register: To hold address of data during memory-to-memory transfer
● Temporary word count register: To hold number of transfers to be performed in memory-to-memory
transfer
● Mode register: 8-bit register which stores the channel to be used, the operating mode, i.e. the transfer
mode, and other transfer parameters
● Command register: 8-bit register which initializes the channel to be used for data transfer
● Request register: 8-bit register used to indicate which channel is requesting for data transfer
● Mask register: 8-bit register used to mask a particular channel from requesting for DMA service
● Status register: 8-bit register used to indicate which channel is currently under DMA service and some
other parameters