I want to compile assemble code (MIPS) by using C, while I came across the problem about "no register name". The error information is:
ABS.c:8:2: error: unknown register name ‘$s1’ in ‘asm’
and my code (ABS.c) are as follow:
#include<stdio.h>
#include<stdlib.h>
int ABS(int x)
{
int x_abs;
__asm__ __volatile__(
"move $s1, %1\n"
"bgez $s1, DONE\n"
"NOP\n"
"mult $s1, #-1\n"
"mflo $s1\n"
"DONE: move %0, $s1\n"
: "=r"(x_abs)
: "r"(x)
: "$s1");
return x_abs;
}
int main()
{
int result = ABS(2);
printf("%d", result);
system("pause");
return 0;
}
I wonder how I could fix that problem, THX!