(1) What is far pointer?
Ans:Far pointer is 32 bit pointer .It can hold the address of variable in the data segment as well as outside of the data segment.
Ans:Far pointer is 32 bit pointer .It can hold the address of variable in the data segment as well as outside of the data segment.
This type modifier is usually used when compiling in the tiny, small or compact memory model to force the pointer to be far. It stores both offset address as well as segment number of any variable But when you will increment far address then only offset address will increase (same way as in near pointer).Its segment number never will change. In dos.h header file there two function that can find offset address and segment address which take the argument far pointer and return unsigned int.
Syntax:
unsigned int FP_OFF(void far *)
unsigned int FP_SEG(void far *)e.g
#include
void main()
{
unsigned int i,offset_addr,seg_addr,;
char far *ptr=(char far *) 5555 FF99;
for (i=0;i<300 data-blogger-escaped-br="" data-blogger-escaped-i="">{
seg_addr=FP_SEG(p);
offset_addr=FP_OFF(p);
printf(“\n seg_addr %x offset_addr %x ”,seg_addr,offset_addr);
p++;
delay(100);
}
}
Output :
Syntax:
unsigned int FP_OFF(void far *)
unsigned int FP_SEG(void far *)e.g
#include
void main()
{
unsigned int i,offset_addr,seg_addr,;
char far *ptr=(char far *) 5555 FF99;
for (i=0;i<300 data-blogger-escaped-br="" data-blogger-escaped-i="">{
seg_addr=FP_SEG(p);
offset_addr=FP_OFF(p);
printf(“\n seg_addr %x offset_addr %x ”,seg_addr,offset_addr);
p++;
delay(100);
}
}
You can see its segment address is not changing. In relational operation whole far address is compared.
No comments:
Post a Comment