- 1、本文档共38页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
嵌入式编译原理3
* Example: if statement C: if (a b) { x = 5; y = c + d; } else x = c - d; Assembler: ; compute and test condition ADR r4,a ; get address for a LDR r0,[r4] ; get value of a ADR r4,b ; get address for b LDR r1,[r4] ; get value for b CMP r0,r1 ; compare a = b BLE fblock ; if a = b, branch to false block * * If statement, cont’d. ; true block MOV r0,#5 ; generate value for x ADR r4,x ; get address for x STR r0,[r4] ; store x ADR r4,c ; get address for c LDR r0,[r4] ; get value of c ADR r4,d ; get address for d LDR r1,[r4] ; get value of d ADD r0,r0,r1 ; compute y ADR r4,y ; get address for y STR r0,[r4] ; store y B after ; branch around false block * * If statement, cont’d. ; false block fblock ADR r4,c ; get address for c LDR r0,[r4] ; get value of c ADR r4,d ; get address for d LDR r1,[r4] ; get value for d SUB r0,r0,r1 ; compute c-d ADR r4,x ; get address for x STR r0,[r4] ; store value of x after ... * * Example: Conditional instruction implementation EXAMPLE2-6 * * Example: switch statement C: switch (test) { case 0: … break; case 1: … } Assembler: ADR r2,test ; get address for test LDR r0,[r2] ; load value for test ADR r1,switchtab LDR r15,[r1,r0,LSL #2] switchtab DCD case0 DCD case1 ... * * Example: FIR filter C: for (i=0, f=0; iN; i++) f = f + c[i]*x[i]; Assembler ; loop initiation code MOV r0,#0 ; use r0 for I MOV r8,#0 ; use separate index for arrays ADR r2,N ; get address for N LDR r1,[r2] ; get value of N MOV r2,#0 ; use r2 for f * * FIR filter, cont’.d ADR r3,c ; load r3 with base of c ADR r5,x ; load r5 with base of x ; loop body loop LDR r4,[r3,r8] ; get c[i] LDR r6,[r5,r8] ; get x[i] MUL r9,r4,r6 ; compute c[i]*x[i] ADD r2,r2,r9 ; add into running sum ADD r8,r8,#4 ; add one word offset to array index ADD r0,r0,#1 ; add 1 to i CMP r0,r1 ; exit? BLT loop ; if i N, continue * * ARM subroutine linkage Branch and link instruction: BL foo Copies current PC to r14. To return from su
您可能关注的文档
- 中国税制基本税款的解释.doc
- 入党转正申请(通用版).doc
- 第01组专业学习网站-调研报告书.doc
- 第19讲小升初计算.doc
- 恶性违章行为定义.doc
- 科学工作计划第六册201202.doc
- 简洁+表单_实用PPT模版.ppt
- 天思经理人ERP机加工行业应用方案V1.1.doc
- 拆除封堵墙施工方案.doc
- 第三节第一单元复习与习题.doc
- 2024年中国钽材市场调查研究报告.docx
- 2024年中国不锈钢清洗车市场调查研究报告.docx
- 2024年中国分类垃圾箱市场调查研究报告.docx
- 2024年中国水气电磁阀市场调查研究报告.docx
- 2024年中国绿藻片市场调查研究报告.docx
- 2010-2023历年初中毕业升学考试(青海西宁卷)数学(带解析).docx
- 2010-2023历年福建厦门高一下学期质量检测地理卷.docx
- 2010-2023历年初中数学单元提优测试卷公式法(带解析).docx
- 2010-2023历年初中毕业升学考试(山东德州卷)化学(带解析).docx
- 2010-2023历年初中毕业升学考试(四川省泸州卷)化学(带解析).docx
最近下载
- 内燃机车钳工(中级)职业鉴定理论考试题及答案.doc VIP
- 聚焦贯彻落实新时代党的组织路线存在不足.docx VIP
- 研究生学术英语读写教程(于华)课后习题答案.pdf
- 跨学科实践活动2 自制净水器(同步课件)-【上好课】2024-2025学年九年级化学上册同步精品课堂(沪教版2024).pptx VIP
- 抗凝剂皮下注射相关并发症及处理对策.docx
- 第十章 甲状腺功能减退症PPT课件.ppt
- 《红楼梦的饮食文化》.docx VIP
- PICMG_COMe R3.0原版标准完整.docx
- ERAS加速康复外科在产科应用进展.pptx VIP
- 河南省南阳市六校2021-2022学年高一上学期第一次联合测试地理试题.pdf VIP
文档评论(0)