delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/07/23/09:34:37

Date: Wed, 23 Jul 2003 08:41:37 -0400
Message-Id: <200307231241.h6NCfbvk000773@envy.delorie.com>
From: DJ Delorie <dj AT delorie DOT com>
To: djgpp AT delorie DOT com
In-reply-to: <84e4e2a9.0307222057.2b678b5d@posting.google.com>
(jbs30000 AT aol DOT com)
Subject: Re: Quick and Easy DJGPP extended inline assembly question.
References: <84e4e2a9 DOT 0307211839 DOT 3b86f7d0 AT posting DOT google DOT com> <200307221324 DOT h6MDOhLl019991 AT envy DOT delorie DOT com> <84e4e2a9 DOT 0307222057 DOT 2b678b5d AT posting DOT google DOT com>
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> __asm__ __volatile__(
> "movw %w0, %%fs\n"
> ".byte 0x64 \n"
> "movb %b1, (%k2)"
> :
> : "rm" (selector), "qi" (value), "r" (offset));
> }

> Looking at the "rm" (selector) and "movw %w0, %%fs" parts, I assume
> that this allows selector to be placed directly into the fs register,
> right?

Yes.  It can be copied from a register ("r") or an immediate value can
be used ("i").

> Also, "qi" (value) moves value directly into al?

"value" gets put into either al, bl, cl, dl ("q"), or an immediate
value can be used ("i").

"offset" is put into any 16-bit register (ax, bx, si, etc) ("r").

In both cases, the compiler will use whatever selection is optimal for
the program.

The "b" in "%b1" means it's a byte.  The "k" in "%k2" means it's a
dword (4 bytes).

- Raw text -


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