This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

core register to C variable



Hello,

I am going to pass information about data abort reason (Data Fault Address Register and Data Fault Status Register) to the application.
I am conscious that I can get value of the register from c15 using this instruction:
__asm(" MRC p15, #0, R11, c6, c0, #0"); /* here I copied value to R11 */
but currently can't do more.

In TI compiler I can't use these commands:
register int dfar __asm("R11"); /* accessing registers using named register variables */
__asm volatile ("MOV %0, LR\n" : "=r" (result) ); /* copy value to variable 'result' */

If I try I get warning: #1493-D GCC-style explicit register variables are not supported"

I found similar issue here:
e2e.ti.com/support/microcontrollers/hercules/f/312/t/280370
but there were no any explanation how to exactly do it.

So, how can I pass value of Data Fault Address Register and Data Fault Status Register to application?

  • I presume you use the TI ARM compiler.

    Write a function in assembly language which returns the value of the register of interest.  Call that function from C code.  To learn how to write that function, please search the TI ARM compiler manual for the sub-chapter titled Interfacing C and C++ With Assembly Language.

    Note that functions implemented in assembly language cannot be inlined.

    Thanks and regards,

    -George