Mail Archives: djgpp/1996/07/19/10:35:36
On Wed, 17 Jul 1996, Richard Philp wrote:
>
> Hi all,
> I've been needing to do some embedded code in some of my programs latly,
> but theres a problem with one of the opcodes: LES . I've try lesl, but the
> assembler doesn't like it, and when I make the program a library, with this
> command in it, it keeps on crashing, and coming up with a sigsev error (Or
> something similer. I know I've misspelt it.). Anyone know why? Or can
> someone give me a reason for why the assembler doesn't like les?
> Or is there an equlivent?
Well, by me the problem lies in what kind of pointers are you using (I assume
you are programming with djgpp - right?). DJGPP is a 32-bit FLAT model
environment and, as such, uses near 32-bit pointers (i.e. ones that have only
the offset part - selector is contained in one of the seg regs and usually
doesn't change). LES instruction requires you to use a selector::offset
address, both in 16- an 32-bit code. When you try to load it from 32-bit flat
mode pointer it stores the 16 upper bits in ES register (which should contain
SELECTOR which is an offset to LDT or GDT table - and NOT the real-mode
segment addres) and the lower 16 bits in UPPER part of the other LES operand
(pretty complicated description - sorry ;-)))) leaving the common 16-bit part
of the register untouched (e.g. ax, bx etc) and possibly containing random
data. To load the ES register successfuly in 32-bits you'd need a 48-bit
pointer (not available directly from DJGPP, except for the farptr routines) of
the form SELECTOR:32_BIT_OFFSET. Then everything would be just fine.
If you want to access some data in assembler with DJGPP just load one of the
indexing 32-bit registers with the pointer value supplied - in most cases you
may safely assume that the corresponding segment registers contains the
correct selector (unless YOU have modified it earlier).
Hope that helps
Mark
/*******************************/
/** So here I am once more... **************************************/
/** When you grown up and leave your playground, where you kissed **/
/** your Prince and found your Frog - remember the Jester that **/
/** showed you tears, a Script for Tears... ************************/
/*********************************************/
- Raw text -