如何在将C代码转换为MIPS后在MARS中运行MIPS?

时间:2015-11-23 03:50:34

标签: mips mips32 mars-simulator

这是代码:

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

int main(void)
{
    puts("Hello World!"); /* prints Hello World! */
    return EXIT_SUCCESS;
}

当我使用tool将C转换为MIPS时,我有一个MIPS代码: 的.text

    .abicalls
    .option pic0
    .section    .mdebug.abi32,"",@progbits
    .nan    legacy
    .set    mips32r2
    .file   "/tmp/webcompile/_26392_0.c"
    .text
    .globl  main
    .align  2
    .type   main,@function
    .set    nomicromips
    .set    nomips16
    .set    mips32r2
    .ent    main
main:
    .frame  $sp,24,$ra
    .mask   0x80000000,-4
    .fmask  0x00000000,0
    .set    noreorder
    .set    nomacro
    .set    noat
    addiu   $sp, $sp, -24
    sw  $ra, 20($sp)
    lui $1, %hi($.str)
    jal puts
    addiu   $4, $1, %lo($.str)
    lw  $ra, 20($sp)
    addiu   $2, $zero, 0
    jr  $ra
    addiu   $sp, $sp, 24
    .set    at
    .set    macro
    .set    reorder
    .end    main
$func_end0:
    .size   main, ($func_end0)-main

    .type   $.str,@object
    .section    .rodata.str1.1,"aMS",@progbits,1
$.str:
    .asciz  "Hello World!"
    .size   $.str, 13


    .ident  "ecc 0.1.13 based on clang version 3.7.0 (trunk) (based on LLVM 3.7.0svn)"
    .section    ".note.GNU-stack","",@progbits
    .text

将所有代码复制到MARS中后构建,它是错误的。

    Error in D:\Desktop old\mips1.asm line 4 column 28:     .section    .mdebug.abi32,"",@progbits
    Error in D:\Desktop old\mips1.asm line 47 column 32:    .section    ".note.GNU-stack","",@progbits

我需要做什么?为什么MIPS代码不能在MARS中运行?

0 个答案:

没有答案