ArticleslgStudy

computer science

Far pointer

Far pointer is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Far pointer rather than just read about it. In short: In a segmented architecture computer, a far pointer is a pointer to memory in a specific context, such as a segment selector 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.

Key takeaways

  • Far pointer belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Far pointer to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Far pointer from memory before moving on to harder problems.

Reference excerpt

In a segmented architecture computer, a far pointer is a pointer to memory in a specific context, such as a segment selector 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, as well as in later processors running 16-bit code, 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 21 bits. 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 normalized to a form with only one representation address. Such a normalized form may be one that minimizes the segment (maximizing the offset), minimizes the offset (maximizing the segment), or converts the 2-part segmented address to a (20-bit) linear representation. One commonly used normalized form minimizes the offset part of the address to a value less than 16 (10 hex): such a normalization can be computed simply by taking the low-order 4 bits of the unnormalized offset as the new offset, and adding to the unnormalized segment the unnormalized offset shifted right by 4 bits. On C compilers targeting the 8086 processor family, far pointers were declared using a non-standard far qualifier; e.g., 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. On other compilers it was done using an equally non-standard __far qualifier. Example of far pointer:

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.

Legacy The Windows API was originally designed for 16-bit x86, and provided typedefs for working with near and far pointers. In the WinAPI convention, the names of far pointer types are prefixed with LP (for long pointer). For example, PDWORD denotes a near pointer to a DWORD, and LPDWORD denotes the corresponding far pointer. In Win32, the older pointer typedefs are retained for backwards-compatibility. Because the need for far pointers was obviated, there was no longer a distinction between the actual types underlying the near and far pointer typedefs. This has resulted in code originally written for Win16 performing redundant pointer type conversions once ported to Win32.

In ESA/390 and z/Architecture On some C compilers for ESA/390 and z/Architecture, far pointers can be used to include an identifier of an alternate address space to access. ESA/370, ESA/390, and z/Architecture include facilities for a program running in one address space to access data in another via "access registers".

On AVR On larger AVR microcontrollers, addressing more than 64 KB is possible via far pointers, which include an identification of the 64 KB "page" to access.

Notes

References

Worked examples

Example 1 — a first encounter with Far pointer

Start with the simplest possible case. Write down what Far pointer claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Far pointer before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Far pointer ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Far pointer

In research
Far pointer appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Far pointer in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Far pointer is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer memory, Pointers (computer programming), so understanding it makes those chapters shorter.
In everyday life
Look for Far pointer outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Far pointer” →

How to study Far pointer in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Far pointer means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Far pointer out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Far pointer in simple terms?

In a segmented architecture computer, a far pointer is a pointer to memory in a specific context, such as a segment selector 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-offs…

Why does Far pointer matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Far pointer?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Far pointer.

Tags

  • Computer memory
  • Pointers (computer programming)

Keep exploring