Could we get a LP64 version identifier?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Tue Jan 27 09:18:29 PST 2009


Walter Bright wrote:
> Frits van Bommel wrote:
>> [1]: Hey, x86 technically has 6-byte pointers if you count segments as 
>> part of the pointer (which would be mostly useless on currently 
>> popular operating systems though).
> 
> It does, but I know of no compiler that supports that (C, C++, or any 
> other), and code that needs to deal with that tends to be assembler.

I never said they were very useful to treat as such. I was just making 
conversation :P.

Segment registers are still used though, in very special cases:
- TLS via fs/gs:<ptr> is probably the only case most programmers will 
ever see in their compiled code, since this is probably the only case 
ever generated by any 32+ bit compilers directly from a high-level 
language (i.e. unless an (inline) assembler is used).
- The VESA (v3) protected mode interface[1] involves calling 16-bit 
protected-mode code located in the BIOS. It requires a data table to be 
set with some 16-bit protected mode segments pointing to BIOS and video 
memory before calling it. Also, calling the 16-bit code in itself 
requires setting segment registers to 16-bit segments. These are only 
32-bit total though, since it uses only 16 bits for the pointer values. 
Still, this is used from 32-bit code.
- OS kernels use different segments than user-level code because of 
protection flags (and in case of x86-64, yet others to run 32-bit 
user-level programs). These tend to overlap each other though, having 
the same data at each accessible address.


[1] This allows writing a "generic" driver for a large variety of video 
cards that supports more resolutions than VGA. IIRC x86-64 doesn't allow 
16-bit protected mode anymore once you're in 64-bit mode, but for 32-bit 
x86 at least this is rather nice.



More information about the Digitalmars-d mailing list