System level programming by c programming language.
In the header file dos.h there are two important structures and union (Remember this structure)
1. struct BYTEREGS {
unsigned char al, ah, bl, bh;
unsigned char cl, ch, dl, dh;
};
2. struct WORDREGS {
unsigned int ax, bx, cx, dx;
unsigned int si, di, cflag, flags;
};
3. union REGS {
struct WORDREGS x;
struct BYTEREGS h;
};
There is function int86() which has been defined in dos.h header file. It is general 8086 software interrupt interface. It will better to explain it by an example.
Write a c program to display mouse pointer?
Answer:
Write a c program to display mouse pointer?
Answer:
void main()
{
union REGS i,o;
i.x.ax=1;
int86(0x33,&i,&o);
getch();
}
Explanation: To write such program interrupt table is necessary.
Complete interrupt table
It is a small part of interrupt table. It has four field input, output, service number and purpose,
now see the first line which is inside the rectangle. To display the mouse pointer assign ax equal to 1 i.e. service number while ax is define in the WORDREGS
struct WORDREGS {
unsigned int ax, bx, cx, dx;
unsigned int si, di, cflag, flags;
};
and WORDRGS is define in the union REGS
union REGS {
struct WORDREGS x;
struct BYTEREGS h;
};
So to access the ax first declare a variable of REGS i.e.
REGS i,o;
To access the ax write i.x.ax (We are using structure variable i because ax is input, see interrupt table)
So to display mouse pointer assign the value of service number:
i.x.ax=1;
To give the this information to microprocessor
We use int86 function. It has three parameters
1. Interrupt number i.e. 0x33
REGS i,o;
To access the ax write i.x.ax (We are using structure variable i because ax is input, see interrupt table)
So to display mouse pointer assign the value of service number:
i.x.ax=1;
To give the this information to microprocessor
We use int86 function. It has three parameters
1. Interrupt number i.e. 0x33
2. union REGS *inputregiste i.e. &i
3. union REGS *outputregiste i.e. &o;
So write: int86 (0x33, &i, &o);
0 comments:
Post a Comment