public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
From: hjl@lucon.org (H.J. Lu)
To: erik.ivanenko@utoronto.ca (Erik Ivanenko)
Cc: gas2@cygnus.com, ian@cygnus.com (Ian Lance Taylor)
Subject: Re: i386 - GAS problem (fwd)
Date: Sat, 21 Mar 1998 22:55:00 -0000	[thread overview]
Message-ID: <m0yGeel-00058JC@ocean.lucon.org> (raw)
In-Reply-To: <ECS9803211657D@utoronto.ca>

> 
> 
> 
> 
> On Fri, 20 Mar 1998 18:02:00 -0500 H.J. Lu wrote:
> 
> > From: H.J. Lu <hjl@lucon.org>
> > Date: Fri, 20 Mar 1998 18:02:00 -0500
> > Subject: Re: i386 - GAS problem (fwd)
> > To: Joel Sherrill <joel@OARcorp.com>
> > Cc: erik.ivanenko@utoronto.ca, gas2@cygnus.com
> > 
> > > Date: Fri, 20 Mar 1998 15:38:16 -0500
> > > From: "erik.ivanenko" <erik.ivanenko@utoronto.ca>
> > > To: Joel Sherrill <joel@OARcorp.com>
> > > Subject: Re: i386 - GAS  problem
> > > 
> > > Joel Sherrill wrote:
> > > 
> > > > Could you put together a small compilable file 
> with this in it?  binutils
> > > > 2.9 is getting closer and we don't want problems 
> like this in there.
> > > 
> > > The following file shows that the ds register is 
> ignored by the lidt and
> > > lgdt instructions.This is also a problem with the 
> GAS I have ( shipped with
> > > gcc-2.7.2.1 , Linux Universe version ).
> > > I suspect this has been there for a while. 
> > > 
> > >  .section .text
> > >  .code16
> > >    movw $0x1000, %ax
> > >  movw    %ax, %ds
> > > 
> > >  lidt    %ds:0x1000
> > >  lidt    0x1000
> > > 
> > >  lgdt    %ds:0x1000
> > >  lgdt    0x1000
> > > 
> > >  .code32
> > > 
> > >  lidt    %ds:0x1000
> > >  lidt    0x1000
> > > 
> > >  lgdt    %ds:0x1000
> > >  lgdt    0x1000
> > > 
> > 
> > They look ok to me. Please tell me if you run into any 
> real problems
> > with your programs.
> > 
> > Correct me if I am wrong. I believe %ds is the default 
> segment
> > register for lidt/lgdt. gas just optimizes it out.
> > 
> > 
> > H.J.
> 
> I don't think that ds is used as a default for these 
> instructions:
> 
> The code that used these instructions loaded ds with 
> 0x100, and used a 0x0 offset.  The lidt failed; a logica 
> analyzer showed memory writes starting at address 0.
> 
> It was re-written into an equivalent form: ds contained 
> 0x0 with offset 0x1000.  That code worked; the logic 
> analyzer showed memory writes starting at address 
> 0x1000.
> 
> The 386sx programmers manual states that the lidt and 
> lgdt instructions take either m16:24 or m16:32 
> arguments.  The manual claims that the address follows 
> the opcode directly.
> 
> I don't have it in front of me,but I will try to remind 
> myself to send you the exact wording on Monday.
> 

Ian, I think lidt/lgdt are only 2 special cases which use
the linear address only. Here is a patch which seems to
work for me.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
Sat Mar 21 22:47:13 1998  H.J. Lu  (hjl@gnu.org)

	* config/tc-i386.c (md_assemble): Don't update "default_seg"
	if the instruction uses linear address only.

	* config/tc-i386.h (LinearAddress): New to indicate the
	instruction using linear address only.

Index: gas/config/tc-i386.c
===================================================================
RCS file: /home/work/cvs/gnu/binutils/gas/config/tc-i386.c,v
retrieving revision 1.30
diff -u -p -r1.30 tc-i386.c
--- gas/config/tc-i386.c	1998/03/21 02:02:54	1.30
+++ gas/config/tc-i386.c	1998/03/22 06:33:14
@@ -1563,7 +1563,7 @@ md_assemble (line)
 
 		    /* Find the default segment for the memory operand.
 		       Used to optimize out explicit segment specifications.  */
-		    if (i.seg)
+		    if (i.seg && !(t->opcode_modifier & LinearAddress))
 		      {
 			unsigned int seg_index;
 
Index: gas/config/tc-i386.h
===================================================================
RCS file: /home/work/cvs/gnu/binutils/gas/config/tc-i386.h,v
retrieving revision 1.17
diff -u -p -r1.17 tc-i386.h
--- gas/config/tc-i386.h	1997/11/01 03:09:10	1.17
+++ gas/config/tc-i386.h	1998/03/22 06:24:59
@@ -297,6 +297,8 @@ typedef struct
 #define Data16 0x20000		/* needs data prefix if in 32-bit mode */
 #define Data32 0x40000		/* needs data prefix if in 16-bit mode */
 #define iclrKludge 0x80000	/* used to convert clr to xor */
+/* Indicate the instruction using linear address only */
+#define LinearAddress 0x100000
 
   /* (opcode_modifier & COMES_IN_ALL_SIZES) is true if the
      instuction comes in byte, word, and dword sizes and is encoded into
Sat Mar 21 22:47:13 1998  H.J. Lu  (hjl@gnu.org)

	* opcode/i386.h (i386_optab): Set "lgdt" and "lidt" to use
	linear address only with LinearAddress in the "opcode_modifier"
	bit.

Index: include/opcode/i386.h
===================================================================
RCS file: /home/work/cvs/gnu/binutils/include/opcode/i386.h,v
retrieving revision 1.20
diff -u -p -r1.20 i386.h
--- include/opcode/i386.h	1997/11/01 03:09:27	1.20
+++ include/opcode/i386.h	1998/03/22 06:25:45
@@ -464,8 +464,8 @@ static const template i386_optab[] = {
 /* protection control */
 {"arpl", 2, 0x63, _, Modrm, { Reg16, Reg16|Mem, 0} },
 {"lar", 2, 0x0f02, _, Modrm|ReverseRegRegmem, { WordReg|Mem, WordReg, 0} },
-{"lgdt", 1, 0x0f01, 2, Modrm, { Mem, 0, 0} },
-{"lidt", 1, 0x0f01, 3, Modrm, { Mem, 0, 0} },
+{"lgdt", 1, 0x0f01, 2, Modrm|LinearAddress, { Mem, 0, 0} },
+{"lidt", 1, 0x0f01, 3, Modrm|LinearAddress, { Mem, 0, 0} },
 {"lldt", 1, 0x0f00, 2, Modrm, { WordReg|Mem, 0, 0} },
 {"lmsw", 1, 0x0f01, 6, Modrm, { WordReg|Mem, 0, 0} },
 {"lsl", 2, 0x0f03, _, Modrm|ReverseRegRegmem, { WordReg|Mem, WordReg, 0} },

       reply	other threads:[~1998-03-21 22:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ECS9803211657D@utoronto.ca>
1998-03-21 22:55 ` H.J. Lu [this message]
1998-03-20 10:32 Joel Sherrill
1998-03-20 15:02 ` H.J. Lu

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=m0yGeel-00058JC@ocean.lucon.org \
    --to=hjl@lucon.org \
    --cc=erik.ivanenko@utoronto.ca \
    --cc=gas2@cygnus.com \
    --cc=ian@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).