通过从C ++参数大会的android [英] pass parameters from C++ to Assembly in android

查看:107
本文介绍了通过从C ++参数大会的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的C ++ code到大会通过以上四个参数。

I am trying to pass more than four parameters from my C++ code to Assembly.

C ++函数如下:

static float armFunction(float, float, float, float, float);

我可以检索从寄存器R0-R3的前四个参数没有任何问题。

I can retrieve the first four parameters from the registers r0-r3 without any problem.

我希望我的第五个浮点参数是在栈上,我应该能够使用堆栈指针SP例如进行访问我尝试加载我的R4像第五个参数:

I expect that my fifth float argument is on the stack and i should be able to access it using the stack pointer sp e.g. I try to load my fifth argument in r4 like :

ldr r4, [sp]

甚至是:

ldr r4, [sp, #-0x4]

但是,这并不工作,并装配code立即用一些堆栈损坏输出退出。

But this doesn't work and the assembly code immediately exits with some stack corruption output.

我的完整的装配code看起来像这样在这里: http://pastie.org/3933875

My complete assembly code looks like this here: http://pastie.org/3933875

推荐答案

我的ASM code毫不费力地从JNI调用读第5个参数从C到ASM。这是前两行我ASM功能:

My asm code has no trouble reading the 5th parameter from a JNI call from C to asm. Here are the first 2 lines of my asm function:

  stmfd    sp!,{r4-r12,lr}
  ldr      r12,[sp,#40]   @ first stack variable

在那里你不需要为preserve任何登记的情况下,第五个参数是堆栈的顶部:

In the case where you're not needing to preserve any registers, the 5th parameter is on the top of the stack:

  ldr r12,[sp]

这篇关于通过从C ++参数大会的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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