Robert D'Attilio(deleted)
|
RE: How to embed (PPC405) assembly in C function
|
Robert D'Attilio(deleted)
06/11/2009 9:58 AM
post31487
|
RE: How to embed (PPC405) assembly in C function
Neil:
Your not kidding...that is pretty obtuse...
Thanks for pointing out using ClockCycles() instead, certainly much
easier for accessing the time base register this way.
robert
-----Original Message-----
From: Neil Schellenberger [mailto:community-noreply@qnx.com]
Sent: Wednesday, June 10, 2009 6:05 PM
To: general-toolchain
Subject: Re: How to embed (PPC405) assembly in C function
Hi Robert,
The gcc extended inline assembly constraint language isn't for the faint
of heart ;-) It's not particularly well documented; what there is can
be found, e.g., here:
http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Extended-Asm.html#Extended-A
sm
In your case you could probably use something like (WARNING: UNCOMPILED
AND UNTESTED):
uint32_t lo, hi, hi2;
__asm__ __volatile__(
"1:mftbu %[hi];"
"mftb %[lo];"
"mftbu %[hi2];"
"cmplw %[hi],%[hi2];"
"bne 1b;"
: [hi] "=r" (hi),
[lo] "=r" (lo),
[hi2] "=r" (hi2));
If this is Neutrino user mode, you might want to consider ClockCycles()
instead. (And note also the SMP warning there.)
Regards,
Neil
On Wed, 2009-06-10 at 17:03 -0400, Robert D'Attilio wrote:
> Hi:
>
> I need to read some hardware special purpose registers that can only
accessed using assembly instructions. Would anyone have some code
snippets that would illustrate doing this. I do have some example macros
taken from the IPL code that look like the following:
>
> #define set_dcr(dcr,val) \
> __asm__ __volatile__( \
> ".ifdef PPC_CPUOP_ENABLED;" \
> ".cpu 403;"
\
> ".endif;"
\
> "mtdcr %0,%1"
\
> : : "i" (dcr), "r" (val) )
>
> But 1) I need to embed several instructions and 2) not clear on the
above syntax .
>
> thanks
>
> PS
>
> Here is the assembly I"m trying to embed
>
> loop:
> mftbu Rx
> mftb Ry
> mftbu Rz
> cmpw Rz, Rx
> bne loop
>
> Note I realize I'll have to find some vacant registers to use for Rx,
Ry and Rz
>
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post31437
>
_______________________________________________
General
http://community.qnx.com/sf/go/post31445
|
|
|