开发者

Compile code in C to MIPS assembly

I wrote a C program that I need to see it in MIPS assembly code.

How do I install or operate a software that takes *.c file to be *.txt or *.something_else to see its MIPS assembly code ?

My OS 开发者_开发知识库is Linux.

Thanks a lot !!

BTW my code is:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define SIZE 128

int main ()

{
    char mychar , string [SIZE];
    int i;
    int count =0 ;  

    printf ("Please enter your string: \n\n");
    fgets (string, SIZE, stdin);

    printf ("Please enter char to find: ");
    mychar = getchar();

    for (i=0 ; string[i] != '\0' ; i++ )
        if ( string[i]  == mychar )
            count++;

    printf ("The char %c appears %d times\n" ,mychar ,count);


    return 0;
}


What you want is a MIPS cross-compiler, unless you're running Linux on a MIPS box, in which case you want a regular MIPS compiler. Here is a howto for setting up a cross compiler on Linux.

Once you've compiled it, you'll want to see the MIPS disassembly. objdump can help you there.


You need to install a MIPS cross-compile library, and then you need to pass -S and one of the -march=mips* options to gcc.


You can use Dan Kegels' excellent and easy to use cross-tool to compile your own MIPS cross compiler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜