ARM汇编访问C全局变量 [英] ARM assembly access to C global variable

查看:83
本文介绍了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 instructionsimport 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天全站免登陆