`
mmdev
  • 浏览: 12955061 次
  • 性别: Icon_minigender_1
  • 来自: 大连
文章分类
社区版块
存档分类
最新评论

raised an exception. cause : undefined instruction

 
阅读更多

Arm 汇编中出现的问题
Arm
汇编程序与 x86 汇编程序差不多。使用” ; ”注释。像 start,loop 之类的顶格写。 ENTRY 示意程序开始, END 示意结束。当然这两个要对齐写。
下面主要介绍我写的第一个 arm 汇编程序吧。它当之无愧是一个难产儿。

《转》Processor<wbr>ARM7TDMI<wbr>raised<wbr>an<wbr>exception.Cause:Undefined<wbr>instruction
我想这个代码一看大家就能看出来是一个新手写出来的。源于那行“ Stop b Stop “。但即使是这样一行代码也是费劲辛苦才产生的。
第一次的 arm 汇编代码中,我并没有加这一行。直接运行程序后,发现报错: Processor ARM7TDMI raised an exception.Cause:Undefined instruction ,单步运行看结果,其实结果已经得到了,可是到最后的时候都会弹出一个报错框,框里面最后一列全都是 Undefined. 这个问题很是费解。但现在我明白了。
为什么会出现这样的问题了?
在多任务操作系统中,程序其实是一个任务,靠系统调度,每个任务其实都是不断循环执行的 。而在嵌入式产品中,程序总是做一个或多个循环,用户关闭了电源才停止运行。而在 Windows 下,你设计的程序不用循环,是因为开发工具给你做了默认的循环程序,而并非不用循环运行。

程序计数器存放的是你下一条指令的地址, cpu 不断地读出指令,解码执行,然后这个值会调整指向已经执行过的指令的下一条指令地址。如果没有循环,程序结束后,它依然会读取下一条指令。可是你的程序已运行结束,没有定义指令供程序计数器读取。这样自然会出现无定义错误。

知道原因后,我想到一个最简单的方法。既然 arm 汇编它自己不会停下来。没有下一条指令的话会报 Undefined ,那我就让它循环。于是就有了上面的代码。即不影响结果。也不报错。可是实际运行完后,程序就不会停,很像是死机。这让我觉得总有些欠缺。
我看了很多安装文件里面自带的例子。发现大多最后的都有一段:
Stop MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SWI 0x123456
既然是 Stop ,猜测这个应该就是让程序停止的代码了。一问,这三行的确就是用中断把程序给停止运行了。但具体代码的含义也说不上来。继续找资料。终于在一个 arm 技术群里面问到了具体的含义。
stop
一段是用来是程序退出的,第一个语句“ MOV r0 #0x18 ”将 r0 赋值为 0x18 ,这个立即数对应于宏 angel_SWIreason_ReportException 。表示 r1 中存放的执行状态。语句“ LDR r1 =0x20026 ”将 r1 的值设置成 ADP_Stopped_ApplicationExit ,该宏表示程序正常退出。然后使用 SWI ,语句“ SWI 0x123456 ”结束程序,将 CPU 的控制权交回调试器手中。
至此一个真正意义上的 arm 汇编程序诞生了

分享到:
评论

相关推荐

    EurekaLog_7.5.0.0_Enterprise

    8)....Added: Exception line highlighting in disassember view in EurekaLog exception dialog and Viewer 9)....Added: Detection/logging Delphi objects in disassembly view 10)..Added: Support for multi-...

    ReactPC.com:-:waving_hand:嗨,我是@ 2Drotz-:eyes:我对...感兴趣-:seedling:我正在学习...-:revolving_hearts:我希望在...上合作-:closed_mailbox_with_raised_flag:如何联系我..

    ReactPC.com :waving_hand: 嗨,我是@ 2Drotz- :eyes: 我对......感兴趣 ... - :seedling: 我目前正在学习...- :revolving_hearts: 我正在寻求合作...- :closed_mailbox_with_raised_flag: 如何到达我...

    ltsana.github.io:GitHub投资组合

    嗨,我是LT.Sana :waving_hand: :...我相信每个人都梦想着他们希望制作一个WebApp,我在这里致力于将其变为现实我在这些领域很熟练如何到达我 :closed_mailbox_with_raised_flag: 网站: 萨那电子邮件: snm.developer@

    Adm.Web:CRUD示例

    Adm.Web :check_mark_button:CRUD示例 :star:普罗耶托 :alien_monster: Este projetoéum CRUD简单。 实体框架核心。... :closed_mailbox_with_raised_flag: Entre em contato comigo .. :envelope: |

    bangnguyendev.github.io:Bang Nguyen-博客

    :post_office: :shield: :gear: 工具 :toolbox: :hammer_and_wrench: :open_book: :books: 语 :rolled-up_newspaper: :sports_medal: :speech_balloon: 我的博客文章 :shooting_star: :closed_mailbox_with_raised_...

    johnlomat.github.io:全栈开发人员产品组合

    :waving_hand: 嗨,我是@johnlomat :eyes: 我对Web开发感兴趣... :seedling: 我目前正在Laravel和Tailwind CSS中学习... :revolving_hearts: 我正在寻求合作...... :closed_mailbox_with_raised_flag: 如何到达我...

    piyushjangid.github.io:我的GitHub个人资料的配置文件

    :waving_hand: 嗨,我是@PiyushJangid :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...

    manojkasundra.github.io:我的GitHub个人资料的配置文件

    :waving_hand: 嗨,我是@manojkasundra :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...

    adirasmadin-ent.github.io:我的GitHub个人资料的配置文件

    :waving_hand: 嗨,我是@ adirasmadin-ent :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...

    mu-ali.github.io:我的GitHub个人资料的配置文件

    :waving_hand: 嗨,我是@ mu-ali :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...

    lingfengxh:使用CSS3 HTML5编写品优购主页、列表页、注册页

    你好呀 :waving_hand: :telescope: 我目前正在... :seedling: 我目前正在... :closed_mailbox_with_raised_flag: 如何联系我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ..

    FermiQ.github.io

    你好呀 :waving_hand: :telescope: 我目前正在研究... ... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...

    Juliana-Pereira:自述文件

    这里有一些想法可以帮助您入门: :telescope: 我目前正在研究...... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实:...-&gt;

    deepinsea:个人介绍

    你好呀 :waving_hand: 这里有一些想法可以帮助您入门: ... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...

    mauriciotxt.github.io:我的GitHub个人资料的配置文件

    :waving_hand: 嗨,我是毛里西奥·科利斯(Mauricio Collis) :eyes: 我对前端开发,UIX和游戏开发感兴趣。 :seedling: 我目前正在学习React,JavaScript和Java ... :closed_mailbox_with_raised_flag: 如何到达我...

    Avik013

    嗨,大家好 :waving_hand: :telescope: 我目前正在研究.... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...与我联系:语言和工具:

    Pangame-indie

    你好呀 :waving_hand: 这里有一些想法可以帮助您入门: ... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...

    idrissioayoub

    你好呀 :waving_hand: 这里有一些想法可以帮助您入门: ... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...

    SpongeBab:GitHub个人资料

    嗨,大家好 :waving_hand: :sparkles: :sparkles: :sparkles: :sparkles: :... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...

    MOINAHADIDJA

    你好呀 :waving_hand: MOINAHADIDJA / MOINAHADIDJA 这里有一些想法可以帮助您... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...

Global site tag (gtag.js) - Google Analytics