Interrupts in 8086


INTERRUPT Services:
On the systems running on DOS based platform, certain i/o services are provided by hardware and the operating system. These services are called ROM-BIOS services and DOS services and are the form of interrupts.
Need for Interrupt: Interrupts are particularly useful when interfacing I/O devices, that provide or require data at relatively low data transfer rate.
Types of Interrupts: There are two types of Interrupts in 8086. They are:
(i)Hardware Interrupts  and
(ii)Software Interrupts
(i) Hardware Interrupts (External Interrupts). 8086 microprocessors support hardware interrupts through:

  • Two pins (17 and 18) that Allow interrupt requests, NMI and INTR
  • One pin that acknowledges, INTA, the interrupt requested on INTR.

INTR and NMI

  • INTR;is a maskable hardware interrupt. The interrupt can be enabled/Diabled using STI/CLI instructions or using more complicated method of updating the FLAGS register with the help of the POPF instruction.
  • When an interrupt occurs, the processor stores FLAGS register into stack, disables further interrupts, fetches from the bus one byte representing interrupt type, and jumps to interrupt processing routine address of which is stored in location 4 * <interrupt type>. Interrupt processing routine should return with the IRET instruction.
  • NMI is a non-maskable interrupt. Interrupt is processed in the same way as the INTR interrupt. Interrupt type of the NMI is 2, i.e. the address of the NMI processing routine is stored in location 0008h. This interrupt has higher priority than the maskable interrupt.

Ex: NMI, INTR. 
(ii) Software Interrupts (Internal Interrupts and Instructions) .Software interrupts are caused by the instructions inserted in the application program. These can be caused by:

  • INT instruction – breakpoint interrupt. This is a type 3 interrupt.
  • INT <interrupt number> instruction – any one interrupt from available 256 interrupts.
  • INTO instruction – interrupt on overflow
  • Single-step interrupt – generated if the TF flag is set. This is a type 1 interrupt. When the CPU processes this interrupt it Clears TF flag before calling the interrupt processing routine.
  • Processor exceptions: Divide Error (Type 0), Unused Opcode (type 6) and Escape opcode (type 7).
  • Software interrupt processing is the same as for the hardware interrupts.

Ex: INT n;(Software Instructions)
Control is provided;through:

    • IF and TF flag bits
    • IRET and IRETD

The figure: below shows the interrupt structure of the 8086 microprocessor based system.

Figure: Interrurp structure

Figure: Interrupt structure

There can be a number of reasons for the interrupt, but the common cause is a request from some devices which need attention of the CPU. So interrupts, are program control interruption based on an External hardware event (External to the CPU) which generally have nothing at All to do with the instructions currently executing; instead, informs the CPU that a device needs some attention. Whenever such External event occurs, the CPU interrupts the currently executing program, services the device, and then returns control back to the program. The CPU provide these services to External device by executing a program called interrupt service routine (ISR).The interrupt can be from hardware initiated interrupt which require CPU attention or software interrupt is a call to a subroutine located in the operating system, Usually the input-output routine. 8086 system working operating under DOS environment support upto 256 interrupts numbered from 00h to FFh (0 to 255);
In the following text we will be interested in the software interrupt, which are initiated by INT n instruction from the application program. The number n identifies the interrupt number which requests the services of DOS or BIOS. The lower 1K memory contain the interrupt vector table (IVT) having 256 entries each of 4 bytes long. This 4 byte entry in lower 1k memory is nothing but the vector address of each interrupt service routing. This address will be loaded in CS:IP before calling the service routine. The execution of the program then starts from this new address which is the address of the interrupt service routine. At the end of the service routine is the RET instruction which causes a return from the interrupt back in the main program.
Under each interrupt, there are a number of services. In this chapter we will restrict to few important KB, Display, file and printer services under interrupt number 10h, 16h, 21h. These services are assigned service number. The procedure to call any service is to load the service number generally in register AH, any attribute in some Specific registers and then calling a particular interrupt under which that service number fall. Some of the important services are listed in the following tables:
Using DOS interrupts
There are nine DOS interrupt services and they are listed in Figure 5. Five of them, interrupts 20h, 25h through 27h and 2fh are “true” DOS interrupt services, each one having a Specifically-defined task associated with it.

Interrupt Number
Dec Hex Description
32 20 Program terminate: come to normal ending
33 21 Function-call umbrella interrupt
34 22 Terminate address
35 23 Break address
36 24 Critical error-handler address
37 25 Absolute Disk read
38 26 Absolute Disk write
39 27 Terminate-but-stay-resident
47 2F Print SPool control (DOS-3 versions only)

Using BIOS Procedures
System I/O procedures are called with the INT instruction (Section 2). The advantage to calling procedures using this instruction is that the programmer need not know the absolute address of the procedure being called or how to link the procedures into the calling program. All you have to know is the interrupt TYPE for the procedure and the format for the parameter(s) that have to be passed to the procedure.
There are twelve BIOS interrupts in All, falling into five groups (Figure 4). For example with INT 10h you can access the video Display services. This interrupt includes 20 subroutines. Obviously, one of the INT 10h parameters is a data value indicating which one of the twenty subroutines is required. In this case, the AH Register is loaded with the number of the subroutine. In addition, the AL, BX, CX and DX registers are used to provide the parameters for this subroutines.

Interrupt
Dec Hex PeripherAL Devices Services
16 10 Video-Display services
19 13 Diskette services
20 14 Communications services
21 15 Cassette-tape services
22 16 Standard keyboard services
23 17 Printer services
Equipment Status Services
17 11 Equipment-list service
18 12 Memory-Size service
26 1A Time and date services
Print-Screen Service
5 5 Print-screen service
Special Service
24 18 Activate ROM-BASIC language
25 19 Activate bootstrap start-up routine

 

error: Content is protected !!