1、实验三,完成一块存储区的拷贝程序——原代码及简单分析.doc

1、实验三,完成一块存储区的拷贝程序——原代码及简单分析.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
1、实验三,完成一块存储区的拷贝程序——原代码及简单分析.doc

1、实验三,完成一块存储区的拷贝程序——原代码及简单分析 原实验程序 该程序的核心思想:使用8字的块传输 核心语句: ldmia r0!, {r4-r11} stmia r1!, {r4-r11} 一次拷贝8个字,所以,需要计算得到num个字需要循环多少次(每次拷贝8字),于是有了循环初值的设置:movs r3,r2, LSR #3 (R2中保存的是NUM:mov r2, #num ) 但是,num一定是8的整倍数的话,显然通过ands r2, r2, #7,z标志会置位,则beq stop;假如num不是8的整倍数,那么R2通过ands r2, r2, #7 就成了逐字拷贝的循环计数初值。 在 wordcopy: ldr r3, [r0], #4 /* a word from the source */ str r3, [r1], #4 /* store a word to the destination */ subs r2, r2, #1 /* decrement the counter */ bne wordcopy 这段代码中,实现了以R2为-1计数的按字拷贝的循环。 这就是验证程序的基本思路。 原代码如下: /*--------------------------*/ /* constant define */ /*--------------------------*/ .global _start /*--------------------------*/ /* code */ /*--------------------------*/ .text .equ num, 20 /* Set number of words to be copied */ _start: ldr r0, =src /* r0 = pointer to source block */ ldr r1, =dst /* r1 = pointer to destination block */ mov r2, #num /* r2 = number of words to copy */ mov sp, #0x400 /* set up stack pointer (r13) */ blockcopy: movs r3,r2, LSR #3 /* number of eight word multiples */ beq copywords /* less than eight words to move ? */ stmfd sp!, {r4-r11} /* save some working registers */ octcopy: ldmia r0!, {r4-r11} /* load 8 words from the source */ stmia r1!, {r4-r11} /* and put them at the destination */ subs r3, r3, #1 /* decrement the counter */ bne octcopy /* ... copy more */ ldmfd sp!, {r4-r11} /* dont need these now - restore originals */ copywords: ands r2, r2, #7 /* number of odd words to copy */ beq stop /* No words left to copy ? */ wordcopy: ldr r3, [r0], #4 /* a word from the source */ str r3, [r1], #4 /* store a word to the destination */ subs r2, r2, #1 /* decrement the counter */ bne wordcopy /* ... copy more */ stop: b stop /*----------------------------------*/ /* make a word pool */ /*----------------------

文档评论(0)

youbika + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档