public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Ravi <ravi@codito.com>
To: binutils@sources.redhat.com
Cc: Ramana Radhakrishnan <ramana.radhakrishnan@codito.com>
Subject: [PATCH] Fix trivial error in opcodes/arc-opc.c
Date: Wed, 17 Nov 2004 12:58:00 -0000	[thread overview]
Message-ID: <419B9822.6080307@codito.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1264 bytes --]

Hello,

I tried to assemble tbe following program for the ARC:

<snip>

.text

    ld r0,[0]

</snip>

However, the assembler gives an error message: 'ld operand error'.

The mentioned testcase tries to a load register from memory location 0. 
It could be any number less than 511.

These are the following definitions of the ld instruction under consideration 
as specified by the A4 manual:

LD<zz><.x><.di>     a,[shimm,shimm] (shimms MUST match)
LD<zz><.x><.di>     a,[limm]

The task can be achieved with the above syntaxes as:

ld r2,[0]   where 0 is treated as a long immediate
ld r2,[0,0] where 0s are treated as a short immediates

The function insert_base chooses the short immediate version, in order to save 
four bytes. whenever possible. However when converting from the shorter to the 
longer version, the increase in the number of operands had not been accounted for. 

Consequently, within the function ld_insert_syntax, the check looking for the
short immediate syntax fails.

The solution to this problem would be to modify ls_operand to reflect the change
to the short immediate syntax. This can be done in the function insert_base.

The attached patch should fix this problem and a testcase has been added for the 
same too.

Regards,
Ravi.



[-- Attachment #2: ChangeLog --]
[-- Type: text/plain, Size: 218 bytes --]

2004-11-17  Ravi Ramaseshan  <ravi.ramaseshan@codito.com>

opcode/ChangeLog

	* opcode/arc-opc.c (insert_base): modifying
          ls_operand[LS_OFFSET] to reflect the change to the short
          immediate syntax.


[-- Attachment #3: arc-ld-operand-shimm.patch --]
[-- Type: text/x-patch, Size: 1603 bytes --]

Index: opcodes/arc-opc.c
===================================================================
RCS file: /cvs/src/src/opcodes/arc-opc.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 arc-opc.c
*** opcodes/arc-opc.c	18 Nov 2002 16:50:03 -0000	1.11
--- opcodes/arc-opc.c	17 Nov 2004 09:37:00 -0000
*************** insert_base (insn, operand, mods, reg, v
*** 938,943 ****
--- 938,944 ----
        shimm_p = 1;
        shimm = value;
        ls_operand[LS_BASE] = OP_SHIMM;
+       ls_operand[LS_OFFSET] = OP_SHIMM;
      }
    else
      {
Index: gas/testsuite/gas/arc/ld.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arc/ld.d,v
retrieving revision 1.2
diff -c -3 -p -r1.2 ld.d
*** gas/testsuite/gas/arc/ld.d	11 Jan 2001 21:20:18 -0000	1.2
--- gas/testsuite/gas/arc/ld.d	17 Nov 2004 09:37:00 -0000
*************** Disassembly of section .text:
*** 11,13 ****
--- 11,14 ----
     8:	08 88 21 00 	00218808     ld.a       r1,\[r3,r4\]
     c:	05 06 21 00 	00210605     ldw.x      r1,\[r2,r3\]
    10:	0d 88 41 00 	0041880d     ldw.x.a    r2,\[r3,r4\]
+   14:	00 80 1f 08 	081f8000     ld         r0,\[0\]
Index: gas/testsuite/gas/arc/ld.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/arc/ld.s,v
retrieving revision 1.2
diff -c -3 -p -r1.2 ld.s
*** gas/testsuite/gas/arc/ld.s	11 Jan 2001 21:20:18 -0000	1.2
--- gas/testsuite/gas/arc/ld.s	17 Nov 2004 09:37:00 -0000
***************
*** 5,7 ****
--- 5,8 ----
  	ld.a	r1,[r3,r4]
  	ldw.x	r1,[r2,r3]
  	ldw.x.a	r2,[r3,r4]
+ 	ld	r0,[0]

             reply	other threads:[~2004-11-17 12:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-17 12:58 Ravi [this message]
2004-11-22 17:46 ` Nick Clifton

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=419B9822.6080307@codito.com \
    --to=ravi@codito.com \
    --cc=binutils@sources.redhat.com \
    --cc=ramana.radhakrishnan@codito.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).