public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
From: Ken Raeburn <raeburn@cygnus.com>
To: baford@schirf.cs.utah.edu (Bryan Ford)
Cc: gas2@cygnus.com
Subject: Re: 16-bit i386 code support in GAS
Date: Wed, 09 Nov 1994 10:49:00 -0000	[thread overview]
Message-ID: <9411091849.AA00797@cujo.cygnus.com> (raw)
In-Reply-To: <9411091519.AA29119@titanic.nynexst.com>

   > (Sorry if this isn't the right place to ask this question;
   > I couldn't find any better address in the GAS documentation...)

Probably bug-gnu-utils is the best publicly advertised place.  The gas2
list at Cygnus is a less advertised one, intended mainly for developers.

   > How difficult would it be to add a feature to the i386 version
   > of GAS to allow it to generate 16-bit i386 code?  It seems like
   > it should be a trivial change - just add a directive that inverts
   > the decision of whether or not to add size prefixes to each
   > instruction, right?  Such a feature would make it possible to
   > avoid the icky old inverted-syntax, non-cross-compiling as86 and
   > ld86 programs for writing boot-related code in Mach (Hurd/Lites)
   > and Linux.
   >
   > So, could someone either add this feature, or point me to the
   > right parts of gas-i386 so I can do it myself, or tell me why
   > it isn't so simple?

No "decision" is being made, at least at run time.  The opcode table has
the prefixes already present for the 16-bit versions of instructions that
need them and absent for the 32-bit versions.  So "addw" would be a
two-byte instruction and "addl" a one-byte instruction.

One way to approach this might be to make the opcode table indicate which
operand size an instruction indicates, independently of the value of the
opcode itself, and add the prefix when a larger-than-byte operand size is
needed and it doesn't match the "current" mode.

Another is to check for 16-bit mode and strip off a size prefix if
present, or add one if the instruction would need one, using some kludge
to figure out whether an instruction's operands are 8- or 32-bit sized.

I'd like to see this work done (but cleanly!), for precisely the reasons
you mention.  Anyone doing kernel or stand-alone program development
currently has to have as86 and ld86 as well as the GNU tools for the
32-bit code.  That's just silly.

For consistent results, you'd probably want the disassembler to work in
16-bit mode too.  Un(?)fortunately, they use separate copies of the opcode
table, laid out in different formats.


I'd also like to have a general overhaul of the i386 back end done.  It's
got lots of other problems, especially some dealing with segment
registers.  I've been thinking about doing some of this work myself, but
if you've got a strong overall understanding of the quirks of the i386
instruction set, and a lot of spare time you want to donate, let me
know...


  reply	other threads:[~1994-11-09 10:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <199411091455.HAA25021@schirf.cs.utah.edu>
1994-11-09  7:20 ` H.J. Lu
1994-11-09 10:49   ` Ken Raeburn [this message]
1994-11-09 11:06     ` Bryan Ford
1994-11-09 23:35       ` Ken Raeburn
1994-11-10  6:57         ` Bryan Ford
1994-11-10 11:51           ` Ken Raeburn
1994-11-09 19:22     ` Rick Sladkey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9411091849.AA00797@cujo.cygnus.com \
    --to=raeburn@cygnus.com \
    --cc=baford@schirf.cs.utah.edu \
    --cc=gas2@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).