public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* strange PowerPc assembler syntax used by gas?
@ 1995-06-29  4:53 Nick Stephen
  1995-07-11  8:49 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Stephen @ 1995-06-29  4:53 UTC (permalink / raw)
  To: gas2, Mike Meissner

The Motorola PowerPC Programming Environments book at
Appendix F-9 defines a simplified branch mnemonic of the
form :

  bne	cr3,	target

where `cr3' is defined at F-1 as `symbol cr3' value `3', these
symbols also being used by the cmp mnemonics etc - I have the
cr symbols #defined to be the appropriate values.


When I assemble or disassemble powerpc code using gas,
I see that the assembler expects

  bne	4*cr3,	target

... this caused me a headache when writing some assembler,
since the former expression (which I had used) assembled
without warning generating erroneous code which disassembles
as

  bne	4*cr0, target

This erroneous code is generated because the least significant
bits of the first argument are masked off and ignored (it is
expecting the value 12, not the value 3), and there is
zero in the most significant bits.

I am not putting forward a patch since I'm not sure of the
correct solution (apart from me rewriting my code which I've
already done!).

I suggest one of the following:

  1) Change the assembler syntax to follow that of Motorola.
     This may involve gcc changes?

  2) Test the bottom bits of the first argument for such
     branches, and report a warning/error if they are set.
     This would give a warning for any assembler code of
     the form defined in the Motorola specification.
     - I believe that this should be done in the `insert_cr'
     function in opcodes/ppc-opc.c

I am working using the 26/05/95 snapshot, I got directory
checksum errors on the 07/06/95 snapshot I downloaded so
was unable to check to see if this problem is still present,
but I believe that it is.

Nick
--
Nick Stephen                    Email: stephen@gr.osf.org
OSF Research Institute          Phone: +33 76 63 48 72
2, Avenue de Vignate            Fax:   +33 76 51 05 32
38610 Gieres - France



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: strange PowerPc assembler syntax used by gas?
  1995-06-29  4:53 strange PowerPc assembler syntax used by gas? Nick Stephen
@ 1995-07-11  8:49 ` Ian Lance Taylor
  1995-07-11 14:23   ` Michael Meissner
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 1995-07-11  8:49 UTC (permalink / raw)
  To: stephen; +Cc: gas2, meissner

   Date: Thu, 29 Jun 95 13:53:16 +0200
   From: Nick Stephen <stephen@gr.osf.org>

   The Motorola PowerPC Programming Environments book at
   Appendix F-9 defines a simplified branch mnemonic of the
   form :

     bne	cr3,	target

   where `cr3' is defined at F-1 as `symbol cr3' value `3', these
   symbols also being used by the cmp mnemonics etc - I have the
   cr symbols #defined to be the appropriate values.

Thanks.  I agree that gas appears to be handling this type of
instruction incorrectly.  I have checked in this patch to ppc-opc.c to
fix it.  As I understand it, it should not require any gcc changes,
because gcc does not rely on the extended branch mnemonics.  Mike,
please correct me if I am wrong (if I'm wrong, we might not want this
patch after all).

Ian

Index: ppc-opc.c
===================================================================
RCS file: /rel/cvsfiles/devo/opcodes/ppc-opc.c,v
retrieving revision 1.15
diff -p -r1.15 ppc-opc.c
*** ppc-opc.c	1995/07/07 22:49:39	1.15
--- ppc-opc.c	1995/07/11 15:47:39
*************** static unsigned long insert_bo PARAMS ((
*** 49,56 ****
  static long extract_bo PARAMS ((unsigned long, int *));
  static unsigned long insert_boe PARAMS ((unsigned long, long, const char **));
  static long extract_boe PARAMS ((unsigned long, int *));
- static unsigned long insert_cr PARAMS ((unsigned long, long, const char **));
- static long extract_cr PARAMS ((unsigned long, int *));
  static unsigned long insert_ds PARAMS ((unsigned long, long, const char **));
  static long extract_ds PARAMS ((unsigned long, int *));
  static unsigned long insert_li PARAMS ((unsigned long, long, const char **));
--- 49,54 ----
*************** const struct powerpc_operand powerpc_ope
*** 178,184 ****
       conditional branch mnemonics, which set the lower two bits of the
       BI field.  This field is optional.  */
  #define CR (BT + 1)
!   { 5, 16, insert_cr, extract_cr, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
  
    /* The D field in a D form instruction.  This is a displacement off
       a register, and implies that the next operand is a register in
--- 176,182 ----
       conditional branch mnemonics, which set the lower two bits of the
       BI field.  This field is optional.  */
  #define CR (BT + 1)
!   { 3, 18, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
  
    /* The D field in a D form instruction.  This is a displacement off
       a register, and implies that the next operand is a register in
*************** extract_boe (insn, invalid)
*** 621,650 ****
        && ! valid_bo (value))
      *invalid = 1;
    return value & 0x1e;
- }
- 
- /* The condition register number portion of the BI field in a B form
-    or XL form instruction.  This is used for the extended conditional
-    branch mnemonics, which set the lower two bits of the BI field.  It
-    is the BI field with the lower two bits ignored.  */
- 
- /*ARGSUSED*/
- static unsigned long
- insert_cr (insn, value, errmsg)
-      unsigned long insn;
-      long value;
-      const char **errmsg;
- {
-   return insn | ((value & 0x1c) << 16);
- }
- 
- /*ARGSUSED*/
- static long
- extract_cr (insn, invalid)
-      unsigned long insn;
-      int *invalid;
- {
-   return (insn >> 16) & 0x1c;
  }
  
  /* The DS field in a DS form instruction.  This is like D, but the
--- 619,624 ----


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: strange PowerPc assembler syntax used by gas?
  1995-07-11  8:49 ` Ian Lance Taylor
@ 1995-07-11 14:23   ` Michael Meissner
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Meissner @ 1995-07-11 14:23 UTC (permalink / raw)
  To: ian; +Cc: stephen, gas2, meissner

|    Date: Thu, 29 Jun 95 13:53:16 +0200
|    From: Nick Stephen <stephen@gr.osf.org>
| 
|    The Motorola PowerPC Programming Environments book at
|    Appendix F-9 defines a simplified branch mnemonic of the
|    form :
| 
|      bne	cr3,	target
| 
|    where `cr3' is defined at F-1 as `symbol cr3' value `3', these
|    symbols also being used by the cmp mnemonics etc - I have the
|    cr symbols #defined to be the appropriate values.
| 
| Thanks.  I agree that gas appears to be handling this type of
| instruction incorrectly.  I have checked in this patch to ppc-opc.c to
| fix it.  As I understand it, it should not require any gcc changes,
| because gcc does not rely on the extended branch mnemonics.  Mike,
| please correct me if I am wrong (if I'm wrong, we might not want this
| patch after all).

Thanks.  No, gcc uses simple numbers for the branch instructions.

| Ian
| 
| Index: ppc-opc.c
| ===================================================================
| RCS file: /rel/cvsfiles/devo/opcodes/ppc-opc.c,v
| retrieving revision 1.15
| diff -p -r1.15 ppc-opc.c
| *** ppc-opc.c	1995/07/07 22:49:39	1.15
| --- ppc-opc.c	1995/07/11 15:47:39
| *************** static unsigned long insert_bo PARAMS ((
| *** 49,56 ****
|   static long extract_bo PARAMS ((unsigned long, int *));
|   static unsigned long insert_boe PARAMS ((unsigned long, long, const char **));
|   static long extract_boe PARAMS ((unsigned long, int *));
| - static unsigned long insert_cr PARAMS ((unsigned long, long, const char **));
| - static long extract_cr PARAMS ((unsigned long, int *));
|   static unsigned long insert_ds PARAMS ((unsigned long, long, const char **));
|   static long extract_ds PARAMS ((unsigned long, int *));
|   static unsigned long insert_li PARAMS ((unsigned long, long, const char **));
| --- 49,54 ----
| *************** const struct powerpc_operand powerpc_ope
| *** 178,184 ****
|        conditional branch mnemonics, which set the lower two bits of the
|        BI field.  This field is optional.  */
|   #define CR (BT + 1)
| !   { 5, 16, insert_cr, extract_cr, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
|   
|     /* The D field in a D form instruction.  This is a displacement off
|        a register, and implies that the next operand is a register in
| --- 176,182 ----
|        conditional branch mnemonics, which set the lower two bits of the
|        BI field.  This field is optional.  */
|   #define CR (BT + 1)
| !   { 3, 18, 0, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL },
|   
|     /* The D field in a D form instruction.  This is a displacement off
|        a register, and implies that the next operand is a register in
| *************** extract_boe (insn, invalid)
| *** 621,650 ****
|         && ! valid_bo (value))
|       *invalid = 1;
|     return value & 0x1e;
| - }
| - 
| - /* The condition register number portion of the BI field in a B form
| -    or XL form instruction.  This is used for the extended conditional
| -    branch mnemonics, which set the lower two bits of the BI field.  It
| -    is the BI field with the lower two bits ignored.  */
| - 
| - /*ARGSUSED*/
| - static unsigned long
| - insert_cr (insn, value, errmsg)
| -      unsigned long insn;
| -      long value;
| -      const char **errmsg;
| - {
| -   return insn | ((value & 0x1c) << 16);
| - }
| - 
| - /*ARGSUSED*/
| - static long
| - extract_cr (insn, invalid)
| -      unsigned long insn;
| -      int *invalid;
| - {
| -   return (insn >> 16) & 0x1c;
|   }
|   
|   /* The DS field in a DS form instruction.  This is like D, but the
| --- 619,624 ----
| 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-07-11 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-06-29  4:53 strange PowerPc assembler syntax used by gas? Nick Stephen
1995-07-11  8:49 ` Ian Lance Taylor
1995-07-11 14:23   ` Michael Meissner

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).