Lot of people are contacting me for more information on interrupts, IVTs and ISRs. I request you to share any information and queries you have on this forum[archived].

Pointers and its types :

  • A near pointer is 16 bit long . It uses the current contents in CS register of CPU. Near pointer is limited to 64KB of memory
  • A Far pointer is 32 bit long and can access more than 64KB , Huge pointers are also 32 bit long but they use normalization procedure .

Addresses are usually stored in Segment:offset pair and u can use the macro MK_FP to create far pointers using Segment and offset addresses . Say segment is 0xB000 and offset is 8000 then MK_FP(0xB000,8000) would give u a far pointer.

The CPU Registers :

Microprocessors usually have internal storage locations to hold intermediate output called 'registers' . There are in all fourteen CPU registers in 80x86 family of processors as given by

(a) Scratch Pad registers : These are data registers , Four in number as given by

  • AX : Accumulator , Pseudo variable _AX
  • BX : Base ,pseudo variable _BX
  • CX : Count ,pseudo variable _CX
  • DX : Data , pseudo variable _DX

These are 16 bit registers that can be accessed either as 16 bit or 8 bit entities.

(b) Segment registers : The 8086 family of processors refers to any memory location as Segment (16 Bit ):offset (16 Bit ) pair . Specific segments are accessed using Segment registers . These are under ,

  • The CS register identifies the code segment , which contains the program currently under execution.
  • Data segment and Extra segment are identified by DS and ES registers
  • The Stack segment is identified by SS segment.

(c) Offset Registes :

  • Instruction Pointer IP
  • Stack Pointer SP
  • Base pointer BP
  • Source Index SI
  • Destination Index DI

(d) Flags Registers :

There are 9 one bit registers and 7 bits are unused.

Interrupts and Interrupt Vector Table

Interrupt occurs as a signal for the microprocessor to stop whatever it is doing currently . It tells the microprocessor that something important has happend and its attention is needed . The signal is usually generated by the hardware , i.e., Say when a key is hit the keyboard interrupt is generated . C provides a library function for generating interrupts called int86().Every interrupt (either software or hardware ) has a number associated with it . For example the number Ketboard interrupt is 9.

When an interrupt is generated , the processor stops its current activity and activates a memory resident routine called Interrupt Service Routine ISR , The addresses of ISRs are stored in low memory area called the Interrupt Vector Table or the IVT.

A sample call to int86() function is given below ,

int86(8,&i,&o)

where i and o are unions of type REGS which is defined as follows

union REGS {
struct WORDREGS x;
struct BYTEREGS h;
};

struct BYTEREGS {
unsigned char al, ah, bl, bh;
unsigned char cl, ch, dl, dh;
};

struct WORDREGS {
unsigned int ax, bx, cx, dx;
unsigned int si, di, cflag, flags;
};