如何在MIPS中向函数添加4个以上的参数? [英] How do I add more than 4 arguments to a function in MIPS?

查看:57
本文介绍了如何在MIPS中向函数添加4个以上的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我要翻译此C ++代码

Okay, so I am to translate this C++ code

funcArr2(12,a2,a3,a4,used1,used2,& used3,& used4);

funcArr2(12, a2, a3, a4, used1, used2, &used3, &used4);

到目前为止,我已经能够翻译a1-a4了

and I have so far been able to translate the a1-a4 with

        li $a0, 12
        addi $a1, $sp, 280
        addi $a2, $sp, 328
        addi $a3, $sp, 376
        **missing code for arguments 5-8**
        jal funcArr2

但是,我对如何继续添加其他参数完全不知所措,我记得含糊地必须将其保存在堆栈中,但是我不记得要这样做的代码.

However, I'm completely at a loss on how to continue adding the other arguments, I remember vaguely having to save it on the stack however I don't remember the code to do that.

推荐答案

您很幸运, Raymond Chen 最近一直在对此进行博客(至少对于NT是这样),并且对该主题进行了详细介绍.

You're in luck, Raymond Chen has been blogging about this recently (for NT at least), and covers the subject in some detail.

在某些MIPS调用约定中,至少在Linux和NT上,即使函数接受少于4个寄存器arg,它们也始终在堆栈上获得16个字节的本地空间".在堆栈上,第5个及以后的整数arg高于该值.

In some MIPS calling conventions, at least Linux and NT, functions always get 16 bytes of "home space" on the stack, even if they accept fewer than 4 register args. The 5th and later integer arg goes above that, on the stack.

这篇关于如何在MIPS中向函数添加4个以上的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆