Computer Viruses
Computer Programming
C Programming

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

585960

Top Answer
User Avatar
Wiki User
2012-02-16 15:45:30
2012-02-16 15:45:30

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.

1
๐Ÿ™
0
๐Ÿคจ
0
๐Ÿ˜ฎ
0
๐Ÿ˜‚
0

Related Questions

User Avatar

Far and near pointer is only introduced in turbo C compiler.When the pointer refers to an address in the same segment it is called near pointer, but when it refers to an address in another segment it is called far pointer.

User Avatar

Never. 'near' and 'far' pointers are outdated by twenty years!

User Avatar

Pointer is a variable that is used to store the memory address of another variable. There are differenr types of pointers: NULL pointer THIS pointer VOID pointer NEAR pointer HUGE pointer FAR pointer WILD pointer

User Avatar

A far pointer is 4 bytes; 2 bytes for the segment, and 2 bytes for the offset.Far and near pointers were used in older, obsolete environments based on the 8086/8088 architecture, such as Windows 3.x and DOS. Modern operating systems, such as Windows XP, Vista, or 7, on a newer processor such as a Core 2, use a linear space where the pointer is more correctly called a huge pointer - the terms near and far are no longer used.Note: sizeof (char far *) will tell you in bytes.

User Avatar

As the name suggests Pointer is used to point towards something ,here in this case it points to another variable and stored at a memory location. Pointer is a variable that stores address of another variable. Different Types of pointers are: 1)Dangling Pointers 2)NULL Pointers 3)This Pointer 4)Generic Pointer 5)Near Pointer 6)Far Pointer

User Avatar

It has to be a pointer all right.Regarding 'far' and 'near': forget it, simply use 'Large' data modell (or 'Huge').

User Avatar

It's an old pointer style that was used when memory was segmented, such as in 16-bit DOS systems. A near pointer was simply treated an offset within the current segment, and could therefore be reduced in length from the normal 2 bytes to just 1 byte, thus conserving memory. A far pointer was used when crossing segments, and required additional information to refer to the segment and the offset within the segment, which would require at least two bytes. In modern systems, memory is not segmented and can be referenced using a full-width pointer (32-bit or 64-bit), thus the concept of near or far pointers is meaningless.

User Avatar

On a near call, the stack pointer is 2 less than its original value. On a far call, it is 4 less.

User Avatar

Pointer types are very specific to the compiler used and oftentimes subject to the target architecture. The concept of a near/far differentiation may not have any meaning on the memory model of your target. This has nothing to do with Linux or whatever OS you choose to use. More information should be provided with the documentation of your compiler.

User Avatar

In the segmented memory model, a near pointer is a memory address that resides in the same segment as the current segment pointer. It had half the memory requirements of a far pointer (which stored the segment and offset, instead of just the offset), but was limited to 1/65536th the maximum distance of the memory that could be referenced. Since the introduction of the flat memory model, all pointers are near pointers, because segments are no longer used in the segmented model addressing. Instead, segments are used for task gates (protected memory), so no normal program would ever access a segment directly. A developer would only need to worry about "near" and "far" pointers on 386s and older processors. It should be noted that other system architectures, such as PowerPC, RISC, and so on, all do not have the concept of segmented memory, and so do not have near or far pointers at all. Instead, all pointers are of the same size and can address any memory location.

User Avatar

On far pointers the comparison operators(== and !=) check the 32 bit value. While >, =,

User Avatar

In Intel 16-bit x86 architecture, memory was arranged in 64K segments. Two 16-bit words were used to address a specific memory location; 16 bits to identify the segment and 16 bits to identify the offset within that segment. A near pointer only requires 16 bits of storage because it refers to memory as an offset into the current segment whereas a far pointer requires the full 32 bits. However, near pointers are only useful in tiny, small or medium memory models. In all other models, pointers are far by default and introducing an explicit near pointer would be disastrous. In 32-bit architecture, there is only one segment of 4GB starting at address 0x0, therefore the concept of near and far pointers is not an issue.

User Avatar

We haven't used near and far addressing for well over a decade. It was common in older systems where memory was addressed by segment and offset. For instance, on a 32-bit system we might use 16-bits to address the segment and 16-bits to address the offset within that segment. If we were referring to an offset within the current segment then we'd use a 16-bit near pointer, but if we needed to refer to another segment then we'd use a 32-bit far pointer. Today we use a normalised pointers.

User Avatar

In most modern computing environments, its just a pointer. If you're doing Win32 or similar, its just a keyword that means nothing. In older environments, such as MS-DOS, as I recall, a far pointer specifies both the data segment and the offset, whereas a near pointer only stored the offset. In a sufficiently small program, everything was in the same segment and the additional overhead of storing the segment information as well was not necessary.

User Avatar

its pointer created for high safety that cant be find by anyone.

User Avatar

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 !

User Avatar

Near, far, and huge pointers are different types of pointers used to reconcile the different addressing models of the Intel 8086/8088 class processors, running in a 16-bit operating system such as Windows 3.x, as well as any of the newer incarnations running in real mode or virtual 8086 mode.A near pointer can address something within one 64Kb memory segment, containing only an offset, and it takes two bytes. The segment is implied by context, and is usually the data segment, selected for the addressing model.A far pointer can address anything in the 1Mb memory1, containing both a segment and an offset, and it takes four bytes.A huge pointer is a normalised far pointer, which means its offset part is always between 00H and 0FH.In 32-bit mode a pointer can address anything in 4Gb memory, containing a flat 32-bit offset, and it takes four bytes. (In this mode segments have no significance.) It only works, however, when there is support for it, such as the WIN32 extension of Windows 3.x.---------------------------------------------------------------------------------------1In the 80286 or higher, running in protected mode, in OS/2, the segment portion of the pointer is actually a descriptor selector, so 1Mb addressibility depends on the operating system environment.far huge near pointer is an oxymoron. far points to memory outside of the normal address space. near points to memory within the normal address space, is the default, and usually is not needed. I've never seen huge before. What is the target architecture?Near, far, and huge pointers are a construct (usually) in the Win16 environment running on an 8086/8088 or later in real mode, such as Visual C/C++ 1.52. In this environment, near pointers are 16 bits, and far and huge pointers are 32 bits.

User Avatar

A pointer, used in business or teaching = ืžึทืฆื‘ึผึดื™ืขึท (matzbia)the specialty pointer used to read the torah = ื™ื“ (yad)

User Avatar

All three of these pointer types are specific to the Intel x86 segmented architecture, and those processors that emulate this architecture. Segmented architecture here refers to memory access. A memory address in this scenario could be an offset from a segment register. The near pointer is a 16-bit entity that contains just the offset from the default data segment register. The far pointer contains the segment address and the offset in a dual 16-bit structure. The huge pointer is the actual memory address, without reference to any segment register.

User Avatar

The pointer that is used when reading the Torah is called a yad

User Avatar

Clarification is needed. The pointer used isn't specific to the Bar Mitzvah ceremony, it is the pointer used whenever the Torah scroll is read. The pointer itself is called a 'yad' which means 'hand'.

User Avatar

far pointer can access memory that is larger than 64kb, sometimes, such as when dealing withvideo memory, a needful thing.Hello, it's 2011 now -- use a 32-bit compiler and forget about 16-bit DOS systems like TurboC. (But if you absolutely have to use TurboC, use Large model (or Huge), and forget about near and far).

User Avatar

Far and near pointers are DOS-specific trouble-makers, you should just forget them... If you are still using TurboC from the previous centaury, simpy select memory modell "Large", and all your pointers will be 'far' by default.

User Avatar

Huge pointers are fully recognised and evaluated for their entire width.Far pointers only allow normal operations to be done to their offset amount and not the segment or paragraph amount.AnswerNear pointers have a size of 2 bytes. They only store the offset of the address the pointer is referencing. An address consisting of only an offset has a range of 0 - 64K bytes starting from the beginning of DGROUP. A near pointer can be incremented and decremented using arithmetic operators (+, -, ++, and --) through the entire address range. Any attempt to increment a near pointer that has a value of 64K (0xffff) will result in a value of 0. This is referred to as wrapping the pointer. A corresponding result can be expected when attempting to decrement a pointer that contains an address of 0, except the result will be 64K instead of 0. In addition to being incremented and decremented, near pointers can be compared to one another using relational operators ( , ==, >= and Ref: http://bdn.borland.com/article/0,1410,18049,00.HTMLManu Dhawan

User Avatar

A pointer is a variable which is used to store address of a variable. They are used to point to another variable.eg:-int *p; // creates a pointer of integer typeint num; // an integer variablep=# //pointer variable p is assigned with address of num


Copyright ยฉ 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.