1

I came across this question in a book - Can two different Far pointers contain two different addresses but refer to the same physical location in memory. The answer was 'YES'. But, for the same question involving Near and Huge pointers, the answer was 'NO'.

P.S. Don't dump this question since Far, Near and Huge pointers are obsolete nowadays.

zx485
  • 28,498
  • 28
  • 50
  • 59
Biswajit Roy
  • 508
  • 2
  • 7
  • 19
  • What is a far pointer? Can you provide a reference to the standard? And add the references for huge and near pointers, too. And - **which question**?? – too honest for this site May 14 '17 at 03:17
  • 2
    Please refer to the link - http://stackoverflow.com/questions/8727122/explain-the-difference-between-near-far-and-huge-pointers-in-c for discussion on far and huge pointers. Refer discussion in - http://stackoverflow.com/questions/1749904/what-is-the-difference-between-far-pointers-and-near-pointers for far and near pointers. – Biswajit Roy May 14 '17 at 03:32
  • Oh, I well know these terms. But there is no standard definition of what thes pointers are! It is not standard C (actually they are against the standard). Different older architectures use thee terms for very different concepts. Withoput context your question is pointless. – too honest for this site May 14 '17 at 04:38

1 Answers1

3

To be using far pointers, you have to be working with primitive 80x86 chips, or modern chips in a compatibility mode. A far pointer consists of a segment number and an offset, but different segment numbers point to overlapping addresses, so different combinations of segment number and offset can point to the same physical address.

The segment number is multiplied by 16 and the offset added to produce the physical address. Hence:

 segment     offset        address
 0x100       0x0030        0x1030
 0x101       0x0020        0x1030

Etc.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • Did you mean same memory addresses being used by different segments? That would be quite messy. A 'stack overflow error' in one program will then lead to assignment errors in another program running simultaneously with it if the compliler wishes to store variables in second program in already occupied segment ! – Biswajit Roy May 14 '17 at 03:46
  • Tell Intel that it is messy. For the most part, 80386 and later chips avoid the purgatory, but down at the core, that's the way 'real mode' still works (AFAIK — did work for a surprisingly long time if it isn't still the case). – Jonathan Leffler May 14 '17 at 03:48
  • There are other architectures which use these terms for different concepts. Such a concept is against the standard. We need more context. – too honest for this site May 14 '17 at 04:39
  • Which other architectures? And how many of them have books written about them that a beginner might be reading? In a sense, it doesn't matter. I've outlined one way in which the phenomenon occurs. There could also be others, but it doesn't matter. – Jonathan Leffler May 14 '17 at 04:43
  • @JonathanLeffler: Out of memory: H8 (Renesas, still in use), some 6800 families including their Sxx current versions (widely used), some other older architectures. On MSP430X different pointer widths also make sense (not sure how they are called by the various compilers, though). There is no information how old the book is nor about which architecture it is. There is a lot of people interested in "historic" systems nowadays. – too honest for this site May 14 '17 at 14:27