c++ - Run ARM coprocessor instructions with sudo -


my goal write coprocessor p15 register, , right i'm trying read it.

i have following example c++ program, first asm instruction simple ror, works fine. second asm instruction, i'm trying read sctlr register.

i compile program g++ test_program.cpp -o test , run ./test or sudo ./test

if run ./test, output:

value: 10   result: 8 illegal instruction 

if run sudo ./test, get:

value: 10   result: 8 

so instruction not working since not printing line "got here" or "sctlr". there else have execute coprocessor read? i'm running on raspberry pi (cortex a-53).

#include <cstdlib> #include <cstdio>  int main(){ unsigned int y, x; x = 16;  //assembly rotate right 1 example asm("mov    %[result], %[value], ror #1"             : [result]"=r" (y) /* rotation result. */            : [value]"r"   (x) /* rotated value. */            : /* no clobbers */     );  printf("value: %x   result: %x\n", x, y);   // assembly read sctlr, program crashes if run unsigned int id = 0; asm("mrc    p15, 0, %[result], c0, c0, 0"            : [result]"=r" (id)  //rotation result.     );  printf("got here\n");  printf("sctlr: %x", id);   return 0; } 


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -