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,086 of 4,675   
   Lars Erdmann to All   
   Referring to a segment   
   17 Aug 20 19:11:28   
   
   From: lars.erdmann@nospicedham.arcor.de   
      
   Hallo,   
      
   I have a question that might be os specific or maybe also linker/loader   
   specific to a certain extent but I don't know of any better place to ask:   
      
   I am developing for OS/2 which, for the most part, is a 32-bit protected   
   mode OS.   
   However, due to its heritage, device drivers are still 16-bit (even   
   though protected mode) and still consist of multiple code and data segments.   
   Each segment is reflected by a descriptor table entry (as always in   
   protected mode) and, this might be OS specific, is assigned a dedicated   
   GDT selector.   
   It is possible to build drivers that not only contain 16-bit segments   
   but also 32-bit segments. Still, these additional 32-bit segments get   
   assigned a GDT selector and the descriptor entry only encompasses the   
   start address and size of the combined 32-bit code of that 32-bit segment.   
      
   Finally, there exists a FLAT GDT code selector and the descriptor it   
   points to defines the whole 4 GB of memory address space as the segment   
   (start address 0, limit = 4GB-1).   
      
      
      
   Here is the question:   
   In a device driver, from 16-bit code, I need to get to the selector of a   
   32-bit segment of the same driver.   
   I was using IBM's alp.exe assembler and this worked in the following way:   
      
   one module, defining all segments (to make them known to linker):   
   KEECode segment dword public uses16 'CODE'   
   KEECode ends   
   ... other segments ...   
   CODE32 segment public dword use32 'CODE'   
   CODE32 ends   
      
      
   another module:   
   CODE32 segment public dword use32 'CODE'   
   CODE32 ends   
      
   KEECode segment dword public uses16 'CODE'   
   ...   
   mov ax,CODE32 ; loads the GDT sel. for the 32-bit code segment into ax   
   ...   
   KEECode ends   
      
      
   On loading the driver, this was resolved by the loader to load the   
   static GDT selector of the 32-bit code segment ("CODE32") into ax.   
      
      
   Now, I am forced to move to the Watcom WASM.EXE assembler.   
   I did the very same as above, but this time, instead of loading the GDT   
   selector for the 32-bit code segment, it is always the FLAT selector   
   that is loaded into ax once the driver is loaded in memory.   
      
   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 ?   
      
      
   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