2013-03-11 145 views
-5

任何人都可以帮助我将下面的C代码转换为MIPS代码吗?我应该使用递归并得到21-2作为最终答案。谢谢!C到MIPS转换

/* 
x is a pointer to a linked list node and is not null. 
Return the min value stored in the linked list. 

Assume each node is stored in memory as an int (value) followed by a pointer to the next node (next), each a word wide. 
You must write it with recursion. */ 

int findMin(node *x) { 
    if(x->next == NULL) 
     return x->value; 
    else { 
     int min = findMin(x->next); 
     if(min < x->value) 
      return min; 
     else 
      return x->value; 
    } 
} 
+6

...使用编译器? – 2013-03-11 05:25:30

+1

这是功课吗? – tjameson 2013-03-11 05:27:02

+0

@tjameson评论的第二段绝对是教授或助教使用的语句。 – 2013-03-11 05:44:23

回答

3

给你:

mips-linux-gnu-gcc -S -o foo.asm foo.c 
+2

有什么方法可以给你一个巨魔标签吗? – 2013-03-11 05:43:25

+0

@EricUrban我真诚地希望如此。那将是一个成就。 – 2013-03-11 05:44:27

+0

我只是希望这个家伙把gcc编译器的输出作为他的作业。他的教授要么非常感动,要么非常困惑,要么让他失望并继续前进。 – 2013-03-11 05:45:30