ARM程序集对C全局变量的访问 [英] ARM assembly access to C global variable

查看:355
本文介绍了ARM程序集对C全局变量的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0056d/Cihcciij.html ,如果我的ARM汇编代码需要访问一个名为globvar的C全局变量,则应使用这样的importload指令:

According to http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0056d/Cihcciij.html , if my ARM assembly code need to access a C global variable named globvar, I should use import and load instructions like that:

    AREA     globals,CODE,READONLY
    EXPORT    asmsubroutine
    IMPORT    globvar
asmsubroutine
    LDR  r1, =globvar   ; read address of globvar into
                        ; r1 from literal pool
    LDR  r0, [r1]
    ADD  r0, r0, #2
    STR  r0, [r1]
    MOV  pc, lr
    END

,但是当我在代码中使用它时,会出现错误,例如"bad instruction import globvar'`. 我正在使用armv7-android-gcc编译器.我也在这个论坛中寻找类似的问题,但是没有得到有用的结果,因此有人可以帮助我吗?非常感谢.

, but when I use it in my code, there is an error as "bad instructionimport globvar'"`. I'm using armv7-android-gcc compiler. I also looked for the analogous problem in this forum, but I get no useful result, so could anybody help me out of this? Thanks a lot.

推荐答案

使用EXTERN globvar代替IMPORT globvar.

这篇关于ARM程序集对C全局变量的访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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