MIPS - 帮助从 C 转换代码
我是 MIPS 的初学者,我正在尝试编写一个简单的代码,该代码可以在内存中小于 10 个单元(例如 9 个单元)的给定数组上运行,并在屏幕上打印最大的数字。
我写了一个 C 代码来解决这个问题,但我不知道如何将它(没有 mips gcc)转换为工作的 MIPS 汇编代码。
我写的代码:
int N = 9 , i = 0 , biggest = 0 ;
int arr [N] = -2 , 3 , 9 , -1 , 5 , 6 , 10 , 52 , 9 ;
while ( i <= N )
{
if ( arr [i] > biggest )
biggest = arr [i] ;
i++ ;
}
printf ( "biggest number is: %d" , biggest ) ;
如果有人能在 MIPS 汇编中编写该代码并向我解释,我将非常高兴。
谢谢 !
I am a beginner in MIPS and I am trying to write a simple code that runs over a given array in memory that is smaller than 10 cells, lets say 9 cells, and prints on screen the biggest number.
I wrote a C code that solves this issue, but I don't know how to convert it (without mips gcc) to a working MIPS assembly code.
The code I wrote:
int N = 9 , i = 0 , biggest = 0 ;
int arr [N] = -2 , 3 , 9 , -1 , 5 , 6 , 10 , 52 , 9 ;
while ( i <= N )
{
if ( arr [i] > biggest )
biggest = arr [i] ;
i++ ;
}
printf ( "biggest number is: %d" , biggest ) ;
I will be more than happy if someone can write that code in MIPS assembly, and explain it to me.
Thank you !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需关注循环,尝试类似的操作:
将其编译为单独的汇编源文件并与主 C 代码链接。
不要忘记从 C 代码中调用该函数:
Just focusing on the loop, try something like that:
Compile this into a separate assembly source file and link with your main C code.
Don't forget to call the function from your C code:
你的初始化有问题...
You have a problem with your initialization...