Biswajit Roy
Biswajit Roy

Reputation: 528

How can two different far pointers contain two different addresses but refer to the same memory location?

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.

Upvotes: 1

Views: 334

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753970

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.

Upvotes: 3

Related Questions