I am learning SPARC Asm and trying to do some simple exercises, mostly learning from the Internet. But my problem is: I cannot assemble the code, and it's hard for me to find any sources on where and how to do that.
My sample code (should calculate the factorial of a given number):
.global silnia
.proc 4
silnia:
save %sp, -96, %sp
subcc %i0, 2, %l0
bneg silnia1
nop
call silnia
sub %i0, 1, %o0
ba koniec
smul %o0, %i0, %i0
silnia1:
ba koniec
mov 1, %i0
koniec:
ret
restore
#include <stdio.h>
extern int silnia(int n);
int main() {
int a, b;
for(b = 0; b <= 13; b++) {
a = silnia(b);
printf("silnia %i = %i\n", b, a);
}
return 0;
}
The command I'm using:
gcc -g -o output silnia.c silnia
Output: a bunch of unrecognized instructions and registers in the .s file, almost 1 error in each line.
I tried it on two different Linux-based OSes: Ubuntu 22.04 and Solaris 11.4 with the same result - it looks like gcc doesn't recognize the ASM syntax. How can I make it run properly?