The code works as expected. I’m working on embedded systems and worry that my specific asm instructions could be changed. Is there a flag to fail compilation every time the generated instruction won’t match the specified ? Ilya German > On 18 Mar 2019, at 13:09, David Brown <david@xxxxxxxxxxxxxxx> wrote: > >> 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@xxxxxxxxxxxxxxx >> <mailto:david@xxxxxxxxxxxxxxx>> 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). >> >