In a
segmented architecture computer, a far pointer is a
pointer which includes a
segment selector
x86 memory segmentation refers to the implementation of memory segmentation in the Intel x86 computer instruction set architecture. Segmentation was introduced on the Intel 8086 in 1978 as a way to allow programs to address more than 64 K ...
, making it possible to point to addresses outside of the default segment.
Comparison and arithmetic on far pointers is problematic: there can be several different segment-offset address pairs pointing to one
physical address.
In 16-bit x86
For example, in an
Intel 8086
The 8086 (also called iAPX 86) is a 16-bit microprocessor chip designed by Intel between early 1976 and June 8, 1978, when it was released. The Intel 8088, released July 1, 1979, is a slightly modified chip with an external 8-bit data bus (allowi ...
, as well as in later processors running
16-bit
16-bit microcomputers are microcomputers that use 16-bit microprocessors.
A 16-bit register can store 216 different values. The range of integer values that can be stored in 16 bits depends on the integer representation used. With the two mos ...
code, a far pointer has two parts: a 16-bit
segment value, and a 16-bit
offset
Offset or Off-Set may refer to:
Arts, entertainment, and media
* "Off-Set", a song by T.I. and Young Thug from the '' Furious 7: Original Motion Picture Soundtrack''
* ''Offset'' (EP), a 2018 EP by singer Kim Chung-ha
* ''Offset'' (film), a 200 ...
value. A linear address is obtained by shifting the binary segment value four times to the left, and then adding the offset value. Hence the effective address is 20 bits (actually 21-bit, which led to the address wraparound and the
Gate A20). There can be up to 4096 different segment-offset address pairs pointing to one physical address. To compare two far pointers, they must first be converted (normalized) to their 20-bit linear representation.
On
C compilers targeting the 8086 processor family, far pointers were declared using a non-standard far qualifier. For example,
char far *p;
defined a far pointer to a
char
Char may refer to:
People
*Char Fontane, American actress
*Char Margolis, American spiritualist
* René Char (1907–1988), French poet
*The Char family of Colombia:
** Fuad Char, Colombian senator
** Alejandro Char Chaljub, mayor of Barranquilla ...
. The difficulty of normalizing far pointers could be avoided with the non-standard huge qualifier.
Example of far pointer:
#include
int main()
:Output of the following program: 81; Because both addresses point to same location.
:Physical Address = (value of segment register) * 0x10 + (value of offset).
:Location pointed to by pointer 'p' is : 0x5555 * 0x10 + 0x0005 = 0x55555
:Location pointed to by pointer 'q' is : 0x5333 * 0x10 + 0x2225 = 0x55555
:So, p and q both point to the same location 0x55555.
References
{{DEFAULTSORT:Far Pointer
Computer memory