From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linuxppc-dev@lists.ozlabs.org
Subject: Re: PowerPC assembler question
Date: Mon, 17 Jun 2013 12:55:55 +1000 [thread overview]
Message-ID: <1371437755.21896.150.camel@pasglop> (raw)
In-Reply-To: <20130616163041.fa5d1f2d41118b39e22241d5@mega-nerd.com>
On Sun, 2013-06-16 at 16:30 +1000, Erik de Castro Lopo wrote:
> Been busy, but I'm back looking at this.
>
> David Laight wrote:
>
> > With a scratch register there are some two instruction sequences.
> > Reusing the destination register something like:
> >
> > addis %r30,%r31,hi(.label - 1b)
> > lwzx %r30,lo(.label - 1b)(%r30)
> >
>
> I've managed to convert that into something gcc understands:
>
> addis 30, 31, (.label-(1b))@ha
> lwz 30, (.label-(1b))@l(30)
>
> The "@l" is the equivalent of lo() and "@ha" is the sign extending
> verions of hi(). Unfortunately, this code segfaults on executiion.
> I suspect that is because I have used the LWZ instruction instead
> of LWZX suggested by David.
No, lwz is the right instruction. The above should work, tried
stepping it in something like gdb to see waht exactly is going on ?
lwzx is a form that takes only registers (adds two registers to make
the address to load from). lwz takes a register and an immediate offset.
Cheers,
Ben.
> Unfortunately gcc doesn't accept LWZX which I found documented
> here:
>
> http://pds.twi.tudelft.nl/vakken/in101/labcourse/instruction-set/lwzx.html
>
> and seems to have LX as a synonym, but that instruction only seems
> to work on registers, not on addresses as we have here.
>
> I'm actually beginning to have a better understanding of the code
> and I've pulled out these snippets code code into a small assember
> program I'm compiling with gcc and running under gdb.
>
> Cheers,
> Erik
next prev parent reply other threads:[~2013-06-17 2:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 23:01 PowerPC assembler question Erik de Castro Lopo
2013-06-09 23:21 ` Benjamin Herrenschmidt
2013-06-10 11:14 ` Erik de Castro Lopo
2013-06-10 12:41 ` David Laight
2013-06-16 6:30 ` Erik de Castro Lopo
2013-06-17 2:55 ` Benjamin Herrenschmidt [this message]
2013-06-10 21:43 ` Benjamin Herrenschmidt
-- strict thread matches above, loose matches on Subject: below --
2013-06-09 23:01 Erik de Castro Lopo
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=1371437755.21896.150.camel@pasglop \
--to=benh@kernel.crashing.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.