fbpx
Wikipedia

Far pointer

In a segmented architecture computer, a far pointer is a pointer to memory in a specific context,[1] 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 edit

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 20 bits (actually 21-bit,[which?] which led to the address wraparound and the Gate A20).[clarification needed] 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; 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.[2]

Example of far pointer:

#include <stdio.h> int main() {  char far *p =(char far *)0x55550005;  char far *q =(char far *)0x53332225;  *p = 80;  (*p)++;  printf("%d",*q);  return 0; } 
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 edit

  1. ^ Miller, Ethan L.; Neville-Neil, George; Benetopoulos, Achilles; Mehra, Pankaj; Bittman, Daniel (December 2023). "Pointers in Far Memory". Communications of the ACM. 66 (12). New York City: Association for Computing Machinery. ISSN 0001-0782. LCCN 61065941. OCLC 1514517. Wikidata Q1120519. Retrieved February 11, 2024.
  2. ^ "Introduction to Open Watcom C/C++". GitHub. 2024. Retrieved February 11, 2024.

pointer, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsourced, material, challenged, removed, find, sources, news, newspapers, books, scholar, jstor, february, 2024, le. This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Far pointer news newspapers books scholar JSTOR February 2024 Learn how and when to remove this template message In a segmented architecture computer a far pointer is a pointer to memory in a specific context 1 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 editFurther information x86 memory models 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 20 bits actually 21 bit which which led to the address wraparound and the Gate A20 clarification needed 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 span class n far span qualifier e g span class kt char span span class w span span class n far span span class w span span class o span span class n p span span class p span defined a far pointer to a char The difficulty of normalizing far pointers could be avoided with the non standard span class n huge span qualifier On other compilers it was done using an equally non standard span class n far span qualifier 2 Example of far pointer include lt stdio h gt int main char far p char far 0x55550005 char far q char far 0x53332225 p 80 p printf d q return 0 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 span class n p span is 0x5555 0x10 0x0005 0x55555 Location pointed to by pointer span class n q span is 0x5333 0x10 0x2225 0x55555 So span class n p span and span class n q span both point to the same location 0x55555 References edit Miller Ethan L Neville Neil George Benetopoulos Achilles Mehra Pankaj Bittman Daniel December 2023 Pointers in Far Memory Communications of the ACM 66 12 New York City Association for Computing Machinery ISSN 0001 0782 LCCN 61065941 OCLC 1514517 Wikidata Q1120519 Retrieved February 11 2024 Introduction to Open Watcom C C GitHub 2024 Retrieved February 11 2024 Retrieved from https en wikipedia org w index php title Far pointer amp oldid 1206163574, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.