GNU replacing obsolete assembly instructions in PowerPc architecture

David Brown david@westcontrol.com
Mon Mar 18 11:33:00 GMT 2019


On 18/03/2019 12:00, ilya german wrote:
> 
> Can i understand from the answer that asm instructions (not
> mnemonics) won't be replaced ?  

Assuming my memory is correct, of course, it means there is no
difference between "mftb r6" and "mfspr r6, 284", or between "mftbu r5"
and "mfspr r5, 285".

However, I think the particular SPR numbers may vary between PPC cores -
earlier I saw 268 and 269 from a google search, while some old code of
mine has 284 and 285.  So you should prefer to write "mftb" and "mftbu"
in your souce code, and let the compiler and assembler turn it into the
correct SPR values for your chip.

But don't worry if you see the mfspr instructions in the disassembly.

And test your code - it should quickly be apparent whether it works or not.

mvh.,

David


> 
> On Mon, Mar 18, 2019 at 12:22 PM David Brown <david@westcontrol.com
> <mailto:david@westcontrol.com>> wrote:
> 
>     On 18/03/2019 10:08, Florian Weimer wrote:
>     > * ilya german:
>     >
>     >> I have a quastion regarding reading TBR registers on PPC p2020
>     e500v2 CPU.
>     >>
>     >> I wrote the following asm instructions to read the TBR:
>     >>
>     >> mftbu r5 /* Read upper Time Base */
>     >> mftb r6 /* Read lower Time Base */
>     >> mftbu r7 /* Read upper Time Base again */
>     >>
>     >> When I compiled (using GNU 4) and viewed the asm instruction I
>     saw that
>     >> *mftbu* and *mftb* were replaced with *mfspr* instruction.
>     >
>     > How did you determine that it was replaced?
>     >
> 
>     I expect he could see it from looking at a disassembly.
> 
>     On The PPC cores, mftb and mftbu are simplified mnemonics, not
>     instructions - they are implemented as "mfspr" instructions on the
>     appropriate SPR registers (268 and 269).
> 



More information about the Gcc-help mailing list