The pointer that can point to or access the entire resident memory of RAM, encompassing all 16 segments, is known as a huge pointer.
The size of a huge pointer is 4 bytes or 32 bits.
What will be output of
following c program?
#include<stdio.h>
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:
The Turbo C compiler, being based on the 8085 microprocessor, operates with a physical memory address represented in 20 bits. The process of converting a 4-byte or 32-bit huge address into a 20-bit actual physical address is referred to as normalization. Formula to calculate physical address:
Example:
What will be physical address of huge address 0X59994444?
Answer:
Huge
address: 0X59994444
Offset
address: 0x4444
Segment
address: 0x5999
Physical
address= Segment address * 0X10 + Offset address
=0X5999
* 0X10 +0X4444
=0X59990
+ 0X4444
=0X5DDD4
In binary: 0101 1101
1101 1101 0100
Note: Each hexadecimal digit is represented by a 4-bit binary number.
When any relational operation is performed between two huge pointers, they are first normalized into actual physical addresses. Example:
What will be output of following c program?
#include<stdio.h>
int main(){
int huge*p=(int huge*)0XC0563331;
int huge*q=(int huge*)0xC2551341;
if(p==q)
printf("Equql");
else
printf("Not equal");
return 0;
}
Output: Equal
Explanation:
As we are aware, huge pointers compare their physical addresses.
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
=0XC3891
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
=0XC3891
Since both huge pointers p
and q
are pointing to the same physical address, the if
condition will evaluate to true.
What will be output of
following c program?
#include<stdio.h>
int main(){
double near *p,far *q;
printf("%d %d %d",sizeof(q),sizeof(p),sizeof(*p));
return 0;
}
Output: 4
2 8
Explanation:
In this scenario:
q
is a far pointer.p
is a near pointer.*p
is a constant of double data type.
Avoid using huge pointers:
Incrementing a huge pointer will affect both the offset and segment addresses, unlike a far pointer which only increments the offset address. If you have limited knowledge about huge pointers and use them inadvertently, you may unintentionally access and modify critical areas like the Interrupt Vector Table (IVT), device driver memory, video memory, etc. This can pose a risk to the stability and integrity of your computer system. Exercise caution when working with such pointers to prevent unintended consequences.
Why there are three types of pointer in Turbo c compiler?
Answer:
Indeed, Turbo C compiler is rooted in the DOS operating system, which in turn is based on the 8085 microprocessor architecture. The 8085 microprocessor represents actual physical addresses in 20 bits. However, due to factors such as simplicity of calculations, ease of access to actual physical addresses, security considerations, etc., C introduces three types of pointers: near, far, and huge pointers. These pointers provide a balance between addressing the intricacies of memory and ensuring practicality and security in program development.
14 comments:
very good information thank you
thanks alot,usefull info.
Awesome Que and Mind Blowing Ans !!
NO.1
Thanks for this information its really useful.
Thanks for this information its really useful.
good
Thank you..
very good questions
Thanks boss for useful information...
Thanks boss for useful information...
1st problem is not executing. Why?
it only return i m in main , not India and Usa.
Hilarious..... But awesome....
It's a great possibility should you play on-line roulette at house but still need the social interaction of being in a land casino. The incontrovertible fact that|proven truth that} human dealers 1xbet are used means live vendor roulette is commonly solely out there to play with actual cash. Over the years, many individuals have tried to beat the casino, and turn roulette—a recreation designed to show a profit for the house—into one on which the player expects to win.
Post a Comment