Interrupt Handling with C
C is sometimes called a high level assembly language because it can call the different interrupts using some of its some defined functions. Some important functions are as follows:
- int86: Invokes MS-DOS interrupts.
- int86x: Invokes MS-DOS interrupt with segment register values.
- intdos: invokes MS-DOS service using registers other than DX and AL
- intdosx: invokes MS-DOS service with segment register values.
- segread: Reads Segment registers
We shall discuss these functions in detail. First of all we discuss some predefined structure and unions that are frequently or necessarily used with these functions.
SREGS Structure
This structure has been defined in dos.h and it is a structure of the segment registers passed to and filled in by the functions, int86x, intdosx and segread. The declaration of the structure is as follows:
struct SREGS {
unsigned int es;
unsigned int cs;
unsigned int ss;
unsigned int ds;
};
REGS union
REGS is the union of two structures. The union REGS has been defined dos.h and it is used to pass information to and from the functions, int86, int86x, intdos and intdosx. The declaration of the union is as follows:
union REGS {
struct WORDREGS x;
struct BYTEREGS h;
};
BYTEREGS and WORDREGS Structures
The BYTEREGES and WORDREGS structures have been defined in dos.h and these are used for storing byte and word registers. The WORGREGS structure allows the user to access the registers of CPU as 16-bit quantities where BYTEREGES structure gives the access to the individual 8-bit registers.
The BITEREGS structure is declared as follows:
struct BYTEREGS {
unsigned char al, ah, bl, bh;
unsigned char cl, ch, dl, dh;
};
And the WORDREGS structure is declared as follows:
struct WORDREGS {
unsigned int ax, bx, cx, dx;
unsigned int si, di, cflag, flags;
};
|