简体   繁体   中英

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.

您需要安装MIPS交叉编译库,然后需要将-S-march=mips*选项之一传递给gcc。

您可以使用Dan Kegels优秀且易于使用的交叉工具来编译您自己的MIPS交叉编译器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM