From: Kazu Hirata <kazu@hxi.com>
To: binutils@sourceware.cygnus.com
Subject: [patch] gas/config/tc-h8300.c (build_bytes): Assemble ldmac correctly.
Date: Sat, 24 Jun 2000 16:23:00 -0000 [thread overview]
Message-ID: <26027.961888992.0@NO-ID-FOUND.mhonarc.org> (raw)
Hi,
Attached is a patch to fix a bug in h8300-hms-as. The original gas
does not assemble the first two lines of the following function
correctly. The last two lines are OK.
/* h8300-hms-gcc -ms -Wall -O2 -fomit-frame-pointer */
void
test ()
{
__asm__ __volatile__ ("ldmac\ter4,mach");
__asm__ __volatile__ ("ldmac\ter5,macl");
__asm__ __volatile__ ("stmac\tmach,er4");
__asm__ __volatile__ ("stmac\tmacl,er5");
}
Without the patch,
00000000 <_test>:
0: 03 64 03 64 ldmac er4,mach <- incorrect
2: 03 75 03 75 ldmac er5,mach <- incorrect
4: 02 24 02 24 stmac mach,er4
6: 02 35 02 35 stmac macl,er5
8: 54 70 54 70 rts
With the patch,
00000000 <_test>:
0: 03 24 03 24 ldmac er4,mach <- correct
2: 03 35 03 35 ldmac er5,macl <- correct
4: 02 24 02 24 stmac mach,er4
6: 02 35 02 35 stmac macl,er5
8: 54 70 54 70 rts
The problem is that the variable 'd' in 'build_bytes ()' is always 0,
meaning the first operand, when processing MACREG. However, as you can
see from the assembly code, when we want to know which half of the mac
register (mach or macl) is used, we have to look at either the first
or second operand depending on ldmac or stmac.
By the way, the existing testsuite (gas/testsuite/gas/h8300/h8300.exp
and macs.s) is correct. The reason this bug got away with a failure is
a coincident that you would never expect. If you change the 32-bit
registers (er0 and er1) used in macs.s to some other 32-bit registers
(say, er4 and er5 just like the above example) and change h8300.exp
accordingly, the original gas would fail.
Thanks,
Kazu
===File ~/gnu/binutils/ChangeLog-tc-h8300===================
2000-06-24 Kazu Hirata <kazu@hxi.com>
* config/tc-h8300.c (build_bytes): Assemble ldmac correctly.
============================================================
===File ~/gnu/binutils/tc-h8300.patch=======================
Index: gas/config/tc-h8300.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-h8300.c,v
retrieving revision 1.6
diff -u -r1.6 tc-h8300.c
--- tc-h8300.c 2000/06/23 05:44:30 1.6
+++ tc-h8300.c 2000/06/24 23:03:03
@@ -1026,7 +1026,12 @@
if (c & MACREG)
{
- nib = 2 + operand[d].reg;
+ if (operand[0].mode == MACREG)
+ /* stmac has mac[hl] as the first operand. */
+ nib = 2 + operand[0].reg;
+ else
+ /* ldmac has mac[hl] as the second operand. */
+ nib = 2 + operand[1].reg;
}
}
nibble_count++;
============================================================
next reply other threads:[~2000-06-24 16:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-24 16:23 Kazu Hirata [this message]
2000-06-25 9:50 Nick Clifton
[not found] <200006242323.QAA05447@cygnus.com>
2000-06-26 20:49 ` Jeffrey A Law
2000-06-27 6:56 Kazu Hirata
2000-06-29 16:45 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=26027.961888992.0@NO-ID-FOUND.mhonarc.org \
--to=kazu@hxi.com \
--cc=binutils@sourceware.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).