如何从臂组件调用C函数时,通过一个很长很长类型的参数? [英] How to pass a long long-typed parameter when calling c function from arm assembly?

查看:86
本文介绍了如何从臂组件调用C函数时,通过一个很长很长类型的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C函数巫婆的样子:

I have a C function witch looks like:

int foo(int a, long long b);

我试图从臂组件调用它,但我不知道如何处理的第二个参数(长长)。

推荐答案

ARM EABI / AAPCS 的指定64位的类型应在2个寄存器它们彼此相邻并且所述第一寄存器必须偶数传递。在小尾数模式高位部分驻留在较高编号的寄存器,而低的部分被放在降低编号之一。在大端模式下,它是反之亦然。

The ARM EABI/AAPCS specifies that 64bit types should be passed in 2 registers which are next to each other and the first register must be even numbered. In little endian mode the high part resides in the higher numbered register, while the low part is put in the lowered numbered one. In big endian mode it's vice versa.

这两个要求都没有,以适应STRD / LDRD指令,这可以节省两个寄存器在一个单一的指令。

Both requirements are there to accomodate the strd/ldrd instructions, which can save two registers in a single instructions.

所以,通过0x0123456789abcdef在小尾数模式的例子中,你必须加载寄存器方式如下:

So, to pass 0x0123456789abcdef for your example in little endian mode you have to load the registers in the following way:

mov r0, a
// R1 is unused
ldr r2, =0x89abcdef
ldr r3, =0x01234567

这篇关于如何从臂组件调用C函数时,通过一个很长很长类型的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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