delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/07/04:02:07

Date: Wed, 7 Jan 1998 11:01:59 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Anthony DOT Appleyard AT umist DOT ac DOT uk
cc: DJGPP AT delorie DOT com
Subject: Re: Operations on conventional memory
In-Reply-To: <1B6D42C6A39@fs2.mt.umist.ac.uk>
Message-ID: <Pine.SUN.3.91.980107110143.4858G-100000@is>
MIME-Version: 1.0

On Tue, 6 Jan 1998, Anthony.Appleyard wrote:

> extern __inline__ void farpokeb(unsigned short selector,
>          unsigned long offset, unsigned char value) {
>   __asm__ __volatile__ ("movw %w0,%%gs\n" " .byte 0x65 \n" " movb %b1,(%k2)"
>       : : "g" (selector), "qi" (value), "r" (offset)); }
> 
>   and its relatives similarly. Which PC instructions can I prefix `byte 0x65'
> to to make them operate on conventional memory? If e.g. I wanted a quick way
> to compile `x &= y', where x is in conventional memory, would this work?:-

There's no magic in the ".byte 0x65" prefix: it just stands for the
GS: segment override (.byte is used to work around the inline assembly
bugs with segment overrides), and the first instruction of the inline
assembly loads GS with the selector (usually, _dos_ds) that can be
used to reference conventional memory.  Any assembly code that loads
a segment register with the _dos_ds selector and then references
memory with the appropriate segment override will access conventional
memory.

However, note that making this do something like "x &= y" is not that
simple, since you need the offset of x from the beginning of _dos_ds,
whereas GCC generates code which only knows about addresses inside its
DS segment, and assumes all offsets are relative to DS segment base
address.  That is why before calling one of the farptr functions you
need to compute the offset first.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019