In this section you will know power of structure and union.


In the header file 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;
};
In there is function int86().It general 8086 software interrupt interface. It will better to explain it by an example.

Write a c program to display mouse.
Ans:

#include
#include
void main()
{
union REGS i,o;
i.x.ax=1;
int86(0x33,&i,&o);
getch();
}
Explanation: To write such program interrupt table is necessary.




To see complete interrupt table click here
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 parametr
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);
(Compelete interrpt table with interrupt number and purpose is aviable at next post

search in content )

(q)Write a c program which restrict the movement of pointer?
Ans:
//restric the x and y cordinate
#include
#include
void main()
{
union REGS i,o;
//show mouse pointer
i.x.ax=1;
int86(0x33,&i,&o);
//x cordinate restiction
i.x.ax=7;
i.x.cx=20;
i.x.dx=300;
int86(0x33,&i,&o);
//y cordinate restriction
i.x.ax=8;
i.x.cx=50;
i.x.dx=250;
int86(0x33,&i,&o);
getch();
}

1 comments:

daiingaebler said...

Casino no deposit bonus codes 2021 - DrmCD
1x 부산광역 출장안마 deposit bonus 과천 출장샵 · 1x 양주 출장샵 deposit bonus · 2x deposit bonus · 3x deposit bonus · 안양 출장마사지 4x deposit bonus 수원 출장안마 · 5x deposit bonus · 6x deposit bonus.

Followers

 
C - Programming -