Far pointer
Encyclopedia
In a segmented architecture
computer, a far pointer is a pointer which includes a segment selector
, making it possible to point to addresses outside of the current segment.
For example, in an Intel 8086
, where an ordinary pointer is just a 16-bit offset within an implied segment, a far pointer has two parts: a 16-bit segment value and a 16-bit offset 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
). Comparison and arithmetic on far pointers is problematic: there can be up to 4096 different segment-offset address pairs pointing to one and the same physical address. To compare two far pointers, they must first be converted (normalized) to their 20-bit linear representation.
On C
compiler
s targeting the 8086 processor family, far pointers were declared using a non-standard far qualifier. For example,
Memory segment
x86 memory segmentation refers to the implementation of memory segmentation on the x86 architecture. Memory is divided into portions that may be addressed by a single index register without changing a 16-bit segment selector. In real mode or V86 mode, a segment is always 64 kilobytes in size . In...
computer, a far pointer is a pointer which includes a segment selector
Memory segment
x86 memory segmentation refers to the implementation of memory segmentation on the x86 architecture. Memory is divided into portions that may be addressed by a single index register without changing a 16-bit segment selector. In real mode or V86 mode, a segment is always 64 kilobytes in size . In...
, making it possible to point to addresses outside of the current segment.
For example, in an Intel 8086
Intel 8086
The 8086 is a 16-bit microprocessor chip designed by Intel between early 1976 and mid-1978, when it was released. The 8086 gave rise to the x86 architecture of Intel's future processors...
, where an ordinary pointer is just a 16-bit offset within an implied segment, a far pointer has two parts: a 16-bit segment value and a 16-bit offset 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
A20 line
The A20 or addressing line 20 is one of the plethora of electrical lines that make up the system bus of an x86-based computer system. The A20 line in particular is used to transmit the 21st bit on the address bus....
). Comparison and arithmetic on far pointers is problematic: there can be up to 4096 different segment-offset address pairs pointing to one and the same physical address. To compare two far pointers, they must first be converted (normalized) to their 20-bit linear representation.
On C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....
compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
s 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. The difficulty of normalizing far pointers could be avoided with the non-standard huge qualifier.