I'm trying to pass an immediate value (12bit size) containing the address of a CSR register into the csr instruction of riscv. Do you have any idea?
int volatile stimulus[] = {0xabbaabba, 0xFFFFFFFF, 0xAAAAAAAA};
void test_csr0(){
int imm1 = stimulus[0];
int imm2 = stimulus[1];
int test = 0x300;
asm volatile (
"lw t1, %[imm1];"
"lw t4, %[imm2];"
"csrrc x0, %[imm3],t2;"
:
:[imm1] "m" (imm1), [imm2] "m" (imm2),[imm3] "I" (test) ); //
the error is the following:
make all
CC test.c
In file included from test.c:12:0:
csr_test/csr_test0.c: In function 'test_csr0':
csr_test/csr_test0.c:19:9: warning: asm operand 2 probably doesn't match constraints
asm volatile (
^~~
csr_test/csr_test0.c:19:9: error: impossible constraint in 'asm'
Is there a way to use an array of const int instead of the normal test variable? What I mean is the following:
void test_csr0() {
unsigned stimulus[] = {0xabbaabba, 0xFFFFFFFF, 0xAAAAAAAA};
int imm1 = stimulus[0];
int imm2 = stimulus[1];
const int test[] = {0x300, 0x25c, 0xc70, 0x7c0};
for (int i; i<4;i++){
asm volatile (
"lw t1, %[imm1];"
"lw t4, %[imm2];"
"csrrc x0, %[imm3],t2;"
:
:[imm1] "m" (imm1), [imm2] "m" (imm2),[imm3] "I" (test[i]) );
}
}
I need to pass all the addresses to this function. Than you again!
User contributions licensed under CC BY-SA 3.0