answersLogoWhite

0


Best Answer

Normalised pointers date back to the days when physical memory was addressed by segment and offset. For instance, on a system with 4,294,967,296 unique memory addresses we might divide those addresses into 65,536 segments of 65,536 addresses each. This means we need 16-bits to address each segment and another 16-bits to address the offsets within those segments.

If the memory we need to access resides in the current segment only then we don't need to specify the segment at all, we can just use a 16-bit pointer known as a near pointer. This means that all pointer arithmetic applies to the offset address only, such that 0xFFFF + 1 = 0x0000.

If we need to access offsets within a particular segment then we need to use a 32-bit pointer to specify both the segment and the offset. For this we can either use a far or a huge pointer.

We say that a huge pointer is normalised because it behaves exactly as we'd expect any 32-bit value to behave: 0x0000FFFF + 1 = 0x00010000.

However, a far pointer is not normalised because it does not behave in the normal way. Using the same example: 0x0000FFFF + 1 = 0x00000000. In other words, only the offset portion of the address is affected by pointer arithmetic.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is normalized pointer as you say huge is normalized but far is not in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is huge pointer generic pointer and far pointer?

Far Pointer is a pointer that is stored using four bytes (32 bits). The bytes are stored little endian or low to high order. A far pointer can access objects up to 16K in size in any memory area. Objects larger than 16K must be accessed using huge pointers This book is basic for c , download and Read this... must required !


What is far and near pointer and how are they used?

It is a matter of the memory model you are using. On old or embedded systems, some memory was outside of the range of a normal pointer. If you have 4 megs of ram you need at least a 22bit pointer to see all of it. But let's say you only have a 16 bit pointer. This means you can only access the first 65K of ram. Odd as it may sound, this was a problem on old computers, and is sometimes an issue on embedded devices with limited processing power. The near and far classifications were a solution. Pointers are near by default. In my example above, the 65K of ram would be accessed with a near pointer. To get past that 16 bit limit, you need a far pointer. Thus: memory within the pointer's range is near. Memory outside of the range is far. Near pointer: char near * ptr; Far pointer: char far * ptr;A far pointer uses both the segment and the offset address to point to a location in memory. A near pointer in contrast uses only the offset address and the default segment. The far pointer can point to any location in memory, whereas the near pointer can only point to a nearby local address.Something that was important 20 years ago. Now you can forget it.


How do you say pointer in spanish?

el puntero


What are near far and huge pointers in C?

A near pointer is a 16 bit pointer to an object contained in the current segment, be it code segment, data segment, stack segment, or extra segment. The compiler can generate code with a near pointer and does not have to concern itself with segment addressing, so using near pointers is fastest, and generates smallest code. The limitation is that you can only access 64kb of data at a time, because that is the size of a segment - 64kb. A near pointer contains only the 16 bit offset of the object within the currently selected segment.A far pointer is a 32 bit pointer to an object anywhere in memory. In order to use it, the compiler must allocate a segment register, load it with the segment portion of the pointer, and then reference memory using the offset portion of the pointer relative to the newly loaded segment register. This takes extra instructions and extra time, so it is the slowest and largest method of accessing memory, but it can access memory that is larger than 64kb, sometimes, such as when dealing with video memory, a needful thing. A far pointer contains a 16 bit segment part and a 16 bit offset part. Still, at any one instant of time, without "touching" segment registers, the program only has access to four 64kb chunks, or segments of memory. If there is a 100kb object involved, code will need to be written to consider its segmentation, even with far pointers.Now, segments overlap. Each segment is 64kb in length, but each one overlaps the next and the prior by 65520 bytes. That means that every address in memory can be addressed by 64kb-1 different combinations of segment:offset pairs. The result is that the total addressible memory was only 1mb, and the total usable memory address space was 500kb to 600kb. That sounds odd, but Intel built it, Microsoft wrote it, and DOS/Windows 3.1 grew up around it. I still have that computer, and it still works just fine.Now the huge pointer. The far pointer suffers because you can not just add one to it and have it point the the next item in memory - you have to consider segment:offset rules, because of the 16 byte offset issue. The huge pointer is a monolithic pointer to some item with a large chunk of memory, and there are no segment:offset boundaries.Well, in order to get that, the pointer to segment:offset calculation has to be done every time you reference the pointer. It does allow you to create and manipulate a single monolithic object that is greater than 64kb, but it has its costs. Far pointers are the normalized pointers of four bytes which are used to access the main memory of the computer ...it can access both the data segment and code segment thus by modifing the offset you can modify refer two different addresses but refer to the same memory .In a generic OS , memory is organised in a segment:offset fashion. Now say, it is of "X" MB and this "X" MB is made up of say "S" number of segments of each segment having "B" Bytes where S*B Bytes=X MB.Near Pointer: A near pointer is that which will only point within the current segment say segment 3 (there are S number of segments numbered 0 to S-1) by containing only offset .Far Pointer: A far pointer is that which will point anywhere in the X MB across segments by containing segment+offset .The numbers X,S and B vary across diff operating system memory models under which you are programming .Say for MS-DOS,X=1MB;B=16 Bytes and S=1Mega Bytes/16 Bytes . Here, near pointer will have 4 bits to express address from 0 to 16 Bytes in a segment . Here, far pointer will have "l" bits for segment part of memory where 2^l=S (Here S should be a multiple of 16 bytes i.e; B=offset memory) and 4 bits for offset part of memory, so far poinetr will have l+4 bits.In DOS only 1 mb (10,48,580 bytes) of memory is accessible. Any of these memory locations are accessed using CPU registers. Under DOS the CPU registers are only 16 bits long. Therefore, the minimum value present in a CPU register could be 0, and maximum 65,535. Then how do we access memory locations beyond 65535th byte? By using two registers (segment and offset) in conjunction. For this the total memory (1 mb) is divided into a number of units each comprising 65,536 (64 kb) locations. Each such unit is called a segment. Each segment always begins at a location number which is exactly divisible by 16. The segment register contains the address where a segment begins, whereas the offset register contains the offset of the data/code from where the segment begins. For example, let us consider the first byte in B block of video memory. The segment address of video memory is B0000h (20-bit address), whereas the offset value of the first byte in the upper 32K block of this segment is 8000h. Since 8000h is a 16-bit address it can be easily placed in the offset register, but how do we store the 20-bit address B0000h in a 16-bit segment register? For this out of B0000h only first four hex digits (16 bits) are stored in segment register. We can afford to do this because a segment address is always a multiple of 16 and hence always contains a 0 as the last digit. Therefore, the first byte in the upper 32K chunk of B block of video memory is referred using segment:offset format as B000h:8000h. Thus, the offset register works relative to segment register. Using both these, we can point to a specific location anywhere in the 1 mb address space.Suppose we want to write a character `A' at location B000:8000. We must convert this address into a form which C understands. This is done by simply writing the segment and offset addresses side by side to obtain a 32 bit address. In our example this address would be 0xB0008000. Now whether C would support this 32 bit address or not depends upon the memory model in use. For example, if we are using a large data model (compact, large, huge) the above address is acceptable. This is because in these models all pointers to data are 32 bits long. As against this, if we are using a small data model (tiny, small, medium) the above address won't work since in these models each pointer is 16 bits long.What if we are working in small data model and still want to access the first byte of the upper 32K chunk of B block of video memory? In such cases both Microsoft C and Turbo C provide a keyword called far.normally Pointers are 32 bit length. which are divided as segment and offset.which are represent asseg : off 0000:0000 . . . 8000:FFFF. . . . FFFF:FFFFfirst 4 hexa digits are segment, last 4 hexa digits are offsetC Program will allocate 64KB (only one segment) memory for data Part (dynamic memory allocation, Local variables).by using 16 bit we can access that memory that's called near pointer(16 bit pointer).suppose we need more than 64KB memory to a program / we want to access a particular memory location (in TSR Program)at the time we neet 32 bit pointer. through 32 bit pointer we can access any segment and offset address.there are 2 types of 32 bit pointers 1. far pointer. 2. Huge Pointer.In TSR programming normally we use far Pointer.The Main Difference between Far and Huge Pointer isFar pointers are not Normalized.Huge pointers are Normalized.First let me state this is based on my current understanding. If someone can update or improve my version I will be grateful:1.For those in hurry far simply means "its not here find it somewhere else in memory" 2. far, near and huge and not a part of the C standard( am I right?)-So the answer to this is: "It depends" Its highly compiler specific and platform(processor) specific.Different processors have different ways to handle memory, and also different amount of memory.when you say "far" you are just telling the compiler find or put this data somewhere else.But the compiler does the hard work for you: writing the instructions to change the segment properly and accessing the correct memory location for you..and that's because it knows the processor..I think previous answers are mostly related to Pentium family of processors..and perhaps turbo C or similar compilers.But remember that is only one of them!Below are the examples which perhaps can have different meanings in different places:1. far int* near a; 2. far int* a; 3. far int *far a;So the best way is to try it out with your compiler and find out.Pointers can either be near, far, or huge. Near pointers refer to the current segment, so neither DS nor CS must be modified to dereference the pointer. They are the fastest pointers, but are limited to point to 64 kilobytes of memory (the current segment).Far pointers contain the new value of DS or CS within them. To use them the register must be changed, the memory dereferenced, and then the register restored. They may reference up to 1 megabyte of memory. Note that pointer arithmetic (addition and subtraction) does not modify the segment portion of the pointer, only its offset. Operations which exceed the bounds of zero or 65535 (0xFFFF) will undergo modulo 64K operation just as any normal 16 bit operation.For example, the code below will wrap around and overwrite itself: char far* myfarptr = (char far*) 0x50000000L ; unsigned long counter ; for(counter=0; counter


How far will a car go on one liter of petrol?

Depends on the gas mileage of the vehicle. Huge difference between, say, a Prius and a Hummer.


What is the difference between structure and pointer?

A structure is a collection of primitives or other structures. A pointer is a memory address. Comparison of the two is like comparing bowling balls to cinder blocks. You can say that a structure defines the layout of the data, while a pointer points to data that is a particular structure.


What the biggest bird?

The ostrich they r completely huge and when I say huge I mean HUGE


What is stray pointer?

stray pointer is a that pointer which pin points nothing or anywhere but we dont know... for example: int *ptr; ptr=new int[10]; //this memory is on heap. and at the end of the programm if we dont delete this memory mean to say if we dont deallocate this memory then this type of pointer is pointing towards nothing or anywhere because when we work on heap deletion of pointer is must if we dont delete pointers than they pin point stray or anywhere so that sort of pointer is stray pointer. i think you understand...


How do you say huge in Punjabi?

The word for "huge" in Punjabi is "ਵਿਸ਼ਾਲ" (vishal).


How bad is the 2009 drought?

Huge huge huge. It cant get worse than... i shouldn't say that . The drought, scientists say, is the biggest we have had in a long time. in a loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong time.


What is a structure pointer?

A pointer is a variable that holds address information. For example, in C++, say you have a Car class and another class that can access Car. Then, declaring Car *car1 =new Car() creates a pointer to a Car object.. The variable "car1" holds an address location.


What is a null macro what is the difference between a null pointer and a null macro?

NULL Macro is simply what is defined as 0 in a macro provided by the libraryNull pointer is a pointer which has 0 or NULL value stored and points to nowhwere still it points to 0x00 i.e. the first memory location of the OSNull pointer != Uninitialized pointer because an uninitialised pointer can point anywhere in the memory location ...but a NULL pointer surely points to no where(but still behind the scene we can say that it only points to 0x00). Never we can retrive a Null pointer location using th"&" operator..neither will malloc/calloc return NULL IF THERE IS SPACE IN THE MEMORY. NULL pointer is unique !!nishantnitb@aol.com