Arm 汇编中出现的问题
Arm 汇编程序与 x86 汇编程序差不多。使用” ; ”注释。像 start,loop 之类的顶格写。 ENTRY 示意程序开始, END 示意结束。当然这两个要对齐写。
下面主要介绍我写的第一个 arm 汇编程序吧。它当之无愧是一个难产儿。
我想这个代码一看大家就能看出来是一个新手写出来的。源于那行“ 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 汇编程序诞生了
分享到:
相关推荐
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-...
例如:The company raised capital through an initial public offering. 90. dismiss:驳回;不受理。例如:The court dismissed the lawsuit due to lack of evidence. 91. celebrity:名人。例如:The ...
ReactPC.com :waving_hand: 嗨,我是@ 2Drotz- :eyes: 我对......感兴趣 ... - :seedling: 我目前正在学习...- :revolving_hearts: 我正在寻求合作...- :closed_mailbox_with_raised_flag: 如何到达我...
嗨,我是LT.Sana :waving_hand: :...我相信每个人都梦想着他们希望制作一个WebApp,我在这里致力于将其变为现实我在这些领域很熟练如何到达我 :closed_mailbox_with_raised_flag: 网站: 萨那电子邮件: snm.developer@
14. forward (v.):转寄,发送,adv.:向前,前进,如:Please forward this message to everyone. 15. delete (v.):删除,如:Accidentally deleted files can be recovered. 16. print (v.):打印,印刷,如:...
例句:His behavior was abnormal, which raised concerns among his friends. 2. absurd:荒谬的,不合理的,用于形容观点或行为极其离奇。 例句:The idea that the earth is flat is absurd in today's ...
Adm.Web :check_mark_button:CRUD示例 :star:普罗耶托 :alien_monster: Este projetoéum CRUD简单。 实体框架核心。... :closed_mailbox_with_raised_flag: Entre em contato comigo .. :envelope: |
12. amount:名词,表示“总数”或“数量”,如:The total amount of money raised was $10,000. (总共筹集了10,000美元。) 13. appear:动词,意为“出现”或“显得”,如:The sun appeared on the horizon. ...
:post_office: :shield: :gear: 工具 :toolbox: :hammer_and_wrench: :open_book: :books: 语 :rolled-up_newspaper: :sports_medal: :speech_balloon: 我的博客文章 :shooting_star: :closed_mailbox_with_raised_...
- 示例:The abnormal behavior of the patient raised concerns among the medical staff. - **aboard** (ad.):在船(飞机,车)上,上船(飞机,车)。 - 示例:All passengers must be aboard the plane ...
:waving_hand: 嗨,我是@johnlomat :eyes: 我对Web开发感兴趣... :seedling: 我目前正在Laravel和Tailwind CSS中学习... :revolving_hearts: 我正在寻求合作...... :closed_mailbox_with_raised_flag: 如何到达我...
:waving_hand: 嗨,我是@PiyushJangid :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...
:waving_hand: 嗨,我是@manojkasundra :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...
:waving_hand: 嗨,我是@ adirasmadin-ent :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...
:waving_hand: 嗨,我是@ mu-ali :eyes: 我感兴趣的是 ... :seedling: 我目前正在学习... :revolving_hearts: 我正在寻求合作... :closed_mailbox_with_raised_flag: 如何到达我...
例如:The abnormal behavior raised concerns among his friends.(这种不正常的行为让他的朋友感到担忧。) ### 3. 学术与教育类词汇 - **academic** (a.):表示“学院的;学术的”。例如:Academic ...
例如:"His absence from the meeting raised some concerns."(他缺席会议引起了关注。) 8. absolute:绝对的,完全的。如:"In mathematics, there are some absolute truths."(在数学中,存在一些绝对真理。)...
- 示例:His suspicious behavior raised questions among his colleagues. 27. **mild** (a.): “温暖的,暖和的;温柔的,味淡的”。此词既可描述气候也可描述性格或口味。 - 示例:The weather was mild and ...
你好呀 :waving_hand: :telescope: 我目前正在... :seedling: 我目前正在... :closed_mailbox_with_raised_flag: 如何联系我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ..
你好呀 :waving_hand: :telescope: 我目前正在研究... ... :closed_mailbox_with_raised_flag: 如何到达我:... :grinning_face_with_smiling_eyes: 代词:... :high_voltage: 有趣的事实: ...