This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] Fix trivial error in opcodes/arc-opc.c
- From: Ravi <ravi at codito dot com>
- To: binutils at sources dot redhat dot com
- Cc: Ramana Radhakrishnan <ramana dot radhakrishnan at codito dot com>
- Date: Wed, 17 Nov 2004 23:57:46 +0530
- Subject: [PATCH] Fix trivial error in opcodes/arc-opc.c
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.
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.
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]