unsigned int read_reg(char *reg_name)
{
unsigned int result;
__asm__ __volatile__ ("sw xxx, %0" : : "r"(result));
return result;
}
The above is a piece of RISC-V code. reg_name is got from CLI, and it's a string, such as "ra" or "x1", etc.
Is there a way to pass the reg_name to the assembly template so that the same function can handle different registers?