Huge pointer in c programming

Huge pointer:

The pointer which can point or access whole the residence memory of RAM i.e. which can access all the 16 segments is known as huge pointer.

Size of huge pointer is 4 byte or 32 bit.

(1)What will be output of following c program?

int main(){
char huge * far *p;
printf("%d %d %d",sizeof(p),sizeof(*p),sizeof(**p));

return 0;

Output: 4 4 1
Explanation: p is huge pointer, *p is far pointer and **p is char type data variable.

Normalization of huge pointer:

Turbo C compiler is based on 8085 microprocessor in which physical address of memory is represented in 20 bit. Conversion of 4 byte or 32 bit huge address into 20 bit actual physical address is known as normalization.

Formula to calculate physical address:


(q) What will be physical address of huge address 0X59994444?


Huge address: 0X59994444
Offset address: 0x4444
Segment address: 0x5999
Physical address= Segment address * 0X10 + Offset address
=0X5999 * 0X10 +0X4444
=0X59990 + 0X4444
In binary: 0101 1101 1101 1101 0100

Note: Each hexadecimal digit is represented in 4 bit binary number.

When any relation operation is performed between two huge pointers first it normalizes in actual physical address.


(q)What will be output of following c program?

int main(){

   int huge*p=(int huge*)0XC0563331;
   int huge*q=(int huge*)0xC2551341;

     printf("Not equal");

   return 0;

Output: Equal
As we know huge pointers compare its physical address.

Physical address of huge pointer p

Huge address: 0XC0563331
Offset address: 0x3331
Segment address: 0XC056
Physical address= Segment address * 0X10 + Offset address
=0XC056 * 0X10 +0X3331
=0XC0560 + 0X3331

Physical address of huge pointer q

Huge address: 0XC2551341
Offset address: 0x1341
Segment address: 0XC255
Physical address= Segment address * 0X10 + Offset address
=0XC255 * 0X10 +0X1341
=0XC2550 + 0X1341
Since both huge pointers p and q are pointing same physical address so if condition will true.

(q)What will be output of following c program?

int main(){

double near *p,far *q;
printf("%d %d %d",sizeof(q),sizeof(p),sizeof(*p));

return 0;

Output: 4 2 8
Explanation: q is far pointer, p is near pointer, *p is double data type constant.

Don’t use huge pointer:

If you will increment huge pointer it will increment both offset and segment address unlike to far pointer which only increments offset address. So if you have little knowledge about huge pointer and you are using huge pointer then you can easily access and modify the IVT, device driver memory, video memory etc. This might be dangerous for your computer.

(q)Why there are three types of pointer in Turbo c compiler?


Turbo c compiler is based on Dos operating system which is based on 8085 microprocessors. In 8085 microprocessor actual physical address is represented in 20 bit. But there are not any pointers which can point 20 bit address. Considering simplicity of calculations, access to actual physical address, security etc. c has introduced three type of pointer i.e. near, far and huge pointer.


sume said...


akanksha said...

great knowledge of pointers

heena said...

can anyone explain near, far pointers in short?

pravs said...

your blog is great and i learned quite a lot..but one thing i would suggest that in 8085 MP physical address is of 16 bits. in 8086 MP the physical address is of 20 bits..

maheshboya said...

huge pointer and far pointer are one and the same??

Kousi said...

excellent explanations... thank u :)

vimal dhanush said...

thankzzzz a lot---------really a learn a lot