Date: Mon, 24 Mar 1997 10:26:12 -0500 (EST) From: Peter Berdeklis To: Eli Zaretskii cc: djgpp AT delorie DOT com Subject: Re: Assembler Help!! In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Sun, 23 Mar 1997, Eli Zaretskii wrote: > On Fri, 21 Mar 1997, Peter Berdeklis wrote: > > > The DJGPP FAQ list says this in section 17.1: > > > > > > * The AT&T assembler does not provide support for multiple-section (aka > > > multi-segment) programs. Unix style systems expect all programs to be > > > single-section. > > > > > > So it seems that you can't do what you want, unless you hack some of > > > the tools involved (don't ask me how, I wouldn't know). > > > > Actually, GAS does accept segment prefixes, but doesn't actually compile > > them correctly. What you need to do is insert the segment override > > prefix byte by hand, e.g. > > > > .byte 0x2E # segment override for CS > > movl _memory, %eax # now _memory is an offset into the CS segment > > The problem is NOT how to use segment prefixes. The problem is how do > you make, say, GS have the value that will point to a certain section. If this is the problem (I didn't read the original post), then I don't understand why there is a problem. You simply load GS with the appropriate selector and use a byte prefix whenever you want to reference that part of memory. How you get the selector has nothing to do with ASM. To load the appropriate selector you would simply do: movw _new_selector, %gs In extended ASM you could do this like so: short new_selector; asm( "movw %0, %%gs" : : "m" (new_selector) ); where "m" indicates a memory operand. Note that you can't specify segment registers in the input/output/clobbered lists. As far as I can tell, the comment about multiple section not being supported by AT&T ASM means that you can't specify that this code or data can go into a specific named "section", which would correspond to a different selector. This problem has been addressed by a fix by Bill Currie. With this fix the assembler emits the section label - I don't know if the linker interprets it correctly. --------------- Peter Berdeklis Dept. of Physics, Univ. of Toronto