home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,088 of 4,675   
   Lars Erdmann to wolfgang kern   
   Re: Referring to a segment   
   21 Aug 20 00:08:19   
   
   From: lars.erdmann@nospicedham.arcor.de   
      
   On 18.08.20 04.19, wolfgang kern wrote:   
   > On 17.08.2020 19:11, Lars Erdmann wrote:   
   >> Hallo,   
   > Hi,   
   > [...]   
   >> What is the proper way to reference this 32-bit code segment so that   
   >> the proper GDT selector (and not the FLAT selector) is loaded into ax ?   
   >> Is this an assembler issue, a linker issue or even both ?   
   >   
   > I always avoided detours with improper tools. Could well be that what   
   > you miss doesn't exist. 16 bit equivalent to 32 bit Flat code cannot be   
   > except if the 16 bit code seg starts at 0:0 which is a pretty bad idea.   
      
   You misunderstood.   
   It is a 32-bit segment (the segment defined by using the USE32   
   directive) that is loaded somewhere in virtual address space, with a   
   linear start address <> 0 and the length of all the combined 32-bit   
   code. It is NOT a flat segment even though it is a 32-bit segment.   
   And this segment is addressed by a GDT selector (and the descriptor that   
   is points to) that happens to have that linear start address and segment   
   limit. This GDT descriptor is created by the OS loader when the driver   
   is loaded.   
   The one thing that annoys me is that one assembler creates an object   
   file that will contain a fixup that will eventually be replaced by the   
   proper GDT selector (created by the OS loader) whereas the other   
   assembler creates a fixup that will eventually be replaced by the FLAT   
   selector.   
   I know too little about the OMF format to understand what these 2   
   assemblers do differently so that the loader will fail in properly   
   fixing up this selector value.   
      
   >   
   > If you need two entries which point to the same memory in the GDT then   
   > just create them or copy one existing and modify it as desired.   
   > I use two such 16/32 pairs for both code and data [in the HMA range so   
   > this memory is accessible by trueRM16 too].   
      
   Yes, it would be possible to dynamically allocate my own GDT descriptor   
   and have that set with the proper linear base address and limit (there   
   are OS kernel functions to do that) but that would create an unnecessary   
   GDT entry that already exists (and GDT entries are a scarce resource for   
   a segmented OS that OS/2 still is).   
      
   Lars   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca