MPMC M3 Ktunotes - In-1
MPMC M3 Ktunotes - In-1
● The stack is a block of memory that may be used for temporarily storing the contents of the
registers inside the CPU. It is a top-down data structure whose elements are accessed using the
stack pointer (SP) which gets decremented by two as we store a data word in the stack and gets
incremented by two as we retrieve a data word from the stack back to the CPU register.
● The stack segment, like any other segment, may have a memory block of a maximum of 64 Kbytes
locations and thus may overlap with any other segments. The stack Segment register (SS) contains
the base address of the stack segment in the memory. In 8086 microprocessor-based system, the
stack is created by loading a 16-bit base address in the Stack Segment (SS) register and a 16-bit
offset address in Stack Pointer (SP). The 20-bit physical address of the stack is computed by
multiplying the contents of the SS register by 10H and then adding the contents of SP to this
product. Here the content of SP is the offset address of the stack.
● When a number of registers have to be stored and retrieved in the stack, the order of retrieval
should be reversed to that of the order of storage. For example, let BX be pushed to the stack first
and DX next. When the stored information has to be retrieved to appropriate registers then the top of
the stack should be popped to DX first and then to BX next. The storage and retrieval in the stack are
in reverse order because the SP is decremented for every write operation into the stack and SP is
1. Write an ALP to change a sequence of nine 2-byte numbers from ascending to descending order. Use
the LIFO property of the stack.
INTERRUPTS IN 8086
The microprocessors allow normal program execution to be interrupted in order to carry out a specific
task/work. The processor can be interrupted in the following ways (sources of interrupts)
1. By an external signal generated by a peripheral
2. By an internal signal generated by a special instruction in the program
3. By an internal signal generated due to an exceptional condition (eg: divide by zero)
The predefined interrupts are only defined by INTEL and INTEL has not provided any
subroutine/procedure to be executed for these interrupts. To use the predefined interrupts the user/
system designer has to write Interrupt Service Routine (ISR) for each interrupt and store them in
memory.
➢ The software interrupts are program instructions. These instructions are inserted at desired
locations in a program. While running a program, if software interrupt instruction is
encountered then the processor initiates an interrupt. The 8086 processor has 256 types of
software interrupts. The software interrupt instruction is INT n, where n is the type number in
the range 0 to 255.
➢ The software interrupts are nonmaskable and have higher priority than hardware interrupts.
3. Hardware Interrupts:
➢ The interrupts initiated by external hardware by sending an appropriate signal to the interrupt
pin of the processor are called hardware interrupts. The 8086 processor has two interrupt pins
INTR and NMI.
➢ The interrupting device can send a type number in the range of 0 to 25510. Therefore, all the
256 types of interrupts can be initiated through INTR pin.
➢ The hardware interrupts initiated through INTR are maskable by clearing the Interrupt Flag
(IF).
➢ The hardware interrupt NMI is nonmaskable and has higher priority than interrupts initiated
through INTR.
Nested interrupt:
Nested interrupt handling is where the software is prepared to accept another interrupt, even
before it finishes handling the current interrupt. This enables you to prioritize interrupts and
make significant improvements to the latency of high priority events at the cost of additional
complexity.
Data Bus Buffer This tristate bidirectional buffer interfaces internal 8259A bus to the microprocessor
system data bus. Control words, status and vector information pass through buffer during read or write
operations.
Read /Write Control Logic This circuit accepts and decodes commands from the CPU. This also allows
the status of the 8259A to be transferred onto the data bus.
Interrupt Request Register (IRR): The interrupts at IRQ input lines are handled by Interrupt Request
Register internally. IRR stores all the interrupt requests in it in order to serve them one by one on a priority
basis.
Priority Resolver This unit determines the priorities of the interrupt requests appearing simultaneously. The
highest priority is selected and stored in the corresponding bit of ISR during the INTA pulse. The IR0 has
the highest priority while the IR7 has the lowest one.
In-Service Register (ISR) This stores all the interrupt requests those are being served, i.e ISR keeps a track
of the requests being served.
Interrupt Mask Register (IMR) This register stores the bits required to mask the interrupts.
Solution:
We know that, after reset, the IP and CS are initialized to form address FFFF0H. Hence, this address must
lie in the EPROM. The address of RAM may be selected anywhere in the 1MB address space of 8086, but
we will select the RAM address such that the address map of the system is continuous.
8 K = (8192)10 = (2000)H
2000H - 0001H = 1FFFH
Implemented as
(PTO)