What does this line in ARM assembly do?
mrc p15, 0, %0, c9, c13, 0" : : "r" (counter)
What is p15? Usually registers are prefixed with r such as in r15.
What is the symbol :: and what are the roles or c9, c1?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Whilst
MRCis a generic co-processor inter-op instruction,cp15is the control processor – which all modern ARM CPUs have and this has been used by ARM as a means of extending the instruction set for on-chip units such as the cache, MMU, performance monitoring and lots else besides.Taking your instruction a bit at a time:
According to the ARM Cortex A7 MPCore Reference the instruction format is:
And on pages 4-11 this is described as a transfer of a CPU register to the performance monitor count register (I guess
count=0and this is a reset of the performance counter).As for the syntax of inline assembler. refer to this for a x86 overview – which is probably similar to ARM.
The
: : "r" (counter)means that the instruction has:counter, and the register this is in should be used as%0.