From: Christophe Lizzi <lizzi@csti.fr>
To: linuxppc-dev@lists.linuxppc.org, doyle@primenet.com
Subject: Re: PowerPC function returning long long
Date: Wed, 13 Oct 1999 08:14:56 +0200 [thread overview]
Message-ID: <199910130614.IAA29151@devl58> (raw)
> I was playing with the inline assembler and the ppc
> timebase facility and created the following function -
> Is there a better way to write the return statement?
>
> Is there a register constraint for a long long register
> (like the "A" constraint for the x86 which returns the
> 64 bit data in edx:eax)?
64 bit values are returned in r3:r4.
I'm definitively not an asm guru, but the following code works:
/*
from PowerPC Microprocessor Family: The Programming Environments,
section 2.2: PowerPC VEA Register Set - Time Base,
IBM Microelectronics - Motorola.
*/
unsigned long long timebase(void)
{
asm( "isync" ); /* discard prefetched instructions */
/* the loop ensures that a consistent pair of values is obtained */
asm("loop:" );
asm("mftbu 3" ); /* load r3 from TBU */
asm("mftb 4" ); /* load r4 from TBL */
asm("mftbu 5" ); /* load r5 from TBU */
asm("cmpw 5, 3"); /* compare r5 and r3 */
asm("bne loop"); /* loop if carry occured */
}
--Christophe
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
next reply other threads:[~1999-10-13 6:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-13 6:14 Christophe Lizzi [this message]
-- strict thread matches above, loose matches on Subject: below --
1999-10-13 4:54 PowerPC function returning long long Bob Doyle
1999-10-13 8:06 ` Gabriel Paubert
1999-10-13 12:27 ` Michael Meissner
1999-10-14 4:12 ` Bob Doyle
1999-10-14 4:35 ` Michael Meissner
1999-10-14 12:44 ` Daniel Jacobowitz
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=199910130614.IAA29151@devl58 \
--to=lizzi@csti.fr \
--cc=doyle@primenet.com \
--cc=linuxppc-dev@lists.linuxppc.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 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 NNTP newsgroup(s).