I have to do this last project of the semester and I have to write it in Assemble Language MIPS. I know how to write in C. But MIPS is going all over my head. Is there any way to convert/translate C to MIPS in .MAL? And then compile it using SPIM in Unix. Thanks
Can you tell me how do it. I tried searching on the internet but no success. Here is an example for my code. Can you convert this for me. Code: /* This program converts the decimal value into a binary value, * along with displaying number of 1 in the result and how * long the 1's sequence is continous. */ #include <stdio.h> // Declaring Variables int x = 0; int y = 0; int z = 0; int a = 0; int b = 0; int c = 0; int dec_num; // Input for the decimal number from the user. int count= 0; // Varibale for counting 1s int dec[64]; // Random Value for storing numbers in an Array /* * Method where user is asked to enter an integer * and it is converted into an binary digits. */ int main(void) { printf("Enter a decimal integer: "); // Asking user for an Integer. scanf("%d", &dec_num); // Reading the inputted Interger Value if(dec_num < 0){ // Finding any Negative Number. printf("\n NEGATIVE NUMBER\n"); // Negative Number cannot work. return 0; // Program Closed } while(dec_num !=0) // If number is more than 0, prog will work. { dec[x] = dec_num%2; // Mod calculation where remainder is chosen. dec_num = dec_num/2; // Divind the number by 2 to make it into binary. x++; // Incrementing, where remainder is taken. } printf("Binary representation = "); // Displaying the final result, Binary Value of an Integer. for(a = x-1; a>=0; a--) // Only numbers 0 and 1 are taken, rest are calculated again. { printf("%d", dec[a]);// Result } printf("\n"); // New Line. for(y=0; y<=x; y++) // Finding number of 1s in the answer. { if(dec[y] == 1) // If any results have 1, then it is taken into a array. { count++; // Added to an Array } } printf("No. of 1's in the binary representation = %d \n", count); // Displaying number of ones in the Binary Value. for(c = 0; c <= x; c++) // Calculating the longest sequence of 1, block. { if(dec[c] == 1) // Finding where the 1 is located in the result. { z++;// Increases the block size when they are 1s in continous. } else if(z > b) // If its more than 1, { b = z;// then it is set to the count z = 0;// and set that to 0. } else { z = 0;// Set to 0 for same reasons as above. } } printf("Maximum block length = %d \n", b); // Displays the longest block for 1s in a sequence. return 0; // TO END THE PROGRAM }// THE END..........
Unfortunately you'll have to read the compiler manual. It's not something I can do for you: (a) because I don't have the compiler or the manual (and in fact I don't think you've told me, but that doesn't matter), and (b) because you need to learn how to find information in manuals, and the best way to do that is to start doing it. And no, I'm not going to translate the code for you; this is either your job and you're being paid to do it, or it's a learning exercise that you'll only learn from by doing it yourself. And besides, MIPS is completely new to me, so why should I go to all the effort needed to learn it just so you can be lazy?
Hi All.. i am using Solaris.. if u r using linux then open a new terminal where you c file exist and just type gcc -S filename.c it will make u an output filename.s in the same folder which contains its assembly Code.. Happy Programming..