Mail Archives: djgpp/1998/01/07/04:02:07
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 -