How to translate C program to MIPS Assembly to work on Spim?

389 views Asked by At

I tried gcc -S Source.c but I must edit produced assembly file Source.s. How should I edit it to work on Spim?

2

There are 2 answers

3
LazerDance On

There isn't any official C to MIPS Assembly compiler but if you insist then give this github a try

1
reza_gp On

try gcc-mips-linux-gnu . first, install it , if you are on Ubuntu you can use sudo apt install gcc-mips-linux-gnu . after that install sudo apt-get install build-essential gcc-mipsel-linux-gnu . now you can try mipsel-linux-gnu-gcc -fverbose-asm -S myprog.c to compile c file. if you didn't have any issue while compiling then you can see through myprog.s to see assembly instructions,it might differ with code can run on simp , specially in syscall instruction that simp have but it is n't identical to it in code that have built with GCC because it have made to run on mips architecture linux system not simp. for further information take a look at this topic , it isn't for working on spim but it might help : link