完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一小段代码,基本上在3个32位数组中初始化3个值。编译后的代码让我好奇为什么这样做…这只是一个为什么处理器内部的问题,这会使它成为“最好”的方法。在DSPIC33 EPMC202优化中的X16 1.25被设置为“S”。我困惑的是目的W0(@ 2076,207C和2082)的后减量。这是32位的“清除”,所以源上的后增量为目的地EA设置W0,但是为什么随后减去目的地W0?为什么不这样做呢?它每次都这样做,即使W0将被加载下面的指令。加载到W0中的常量是每个数组的基地址(是的,每个数组都包含3个32位值)。这也可以用第二个CLR来完成吗?或者:或者,看起来这三种方式之间没有尺寸差异,但是间接MOVs看起来可能会招致1个周期的失速。
以上来自于百度翻译 以下为原文 I have this small section of code which basically initializes 3 values in 3 32-bit arrays. The compiled code has me curious why it was done this way... This is just a why question of what's internal to the processor which would make this the "best" way. X16 1.25 on a dspic33EPMC202 Optimization is set to "s" 1509: array1[const_index] = 0; 002072 218160 MOV #0x1816, W0 002074 EB0800 CLR [W0] 002076 781030 MOV [W0++], [W0--] 1510: array2[const_index] = array1[const_index]; 002078 218220 MOV #0x1822, W0 00207A EB0800 CLR [W0] 00207C 781030 MOV [W0++], [W0--] 1511: array_n1[const_index] = 0; 00207E 21FE80 MOV #0x1FE8, W0 002080 EB0800 CLR [W0] 002082 781030 MOV [W0++], [W0--] What has me confused is the post-decrement of destination W0 (@2076, 207C, and 2082) . This is a 32-bit "clear" so the post-increment on the source sets up W0 for the destination EA, but why then post-decrement the destination W0? Why not do this? MOV [W0++],[W0] It does this every time even though W0 will be loaded with the following instruction. The constants loaded into W0 are the base address of each array (yes, each array holds 3 32-bit values). Could this have also been accomplished with a second CLR? Either: CLR [W0++] CLR [W0++] or: CLR[w0++] CLR[w0] It appears there would be no size difference between the three ways, but the indirect MOVs looks like they may incur a 1 cycle stall. |
|
相关推荐
2个回答
|
|
每个指令占用相同的空间并在同一时间执行。没有理由偏爱一个。“MOV [W0++],[-W0] ]将指向W0的字复制到下一个位置,而不改变W0。显然,在这里不需要保存W0的值,但是它不会伤害到其他的。它们可以用其他方式来补充。
以上来自于百度翻译 以下为原文 Every instruction takes the same space and executes in the same time. There's no reason to prefer one over the other. "mov [w0++],[--w0]" copies the word pointed to be w0 to the next location without altering w0. Apparently, preserving the value of w0 is not required here, but it doesn't hurt nether. They could've done clr [w0++] clr [w0--] or clr [w0++] clr [w0] clr [w0] clr [++w0] or gazillion other ways. |
|
|
|
谢谢,我也在想,目的地寻址邮局也没什么区别。查看它,我发现间接POST/DEC寻址移动的摊位。只是想知道这是否是流水线优化,或者是编译器可以完成任务的几个选项中的第一个。
以上来自于百度翻译 以下为原文 Thanks, was thinking the same thing that the destination addressing post doesn't make any difference. Looking into it I discovered stalls on indirect post inc/dec addressing for moves. Just wondered if this was a pipeline optimization or rather the first of several options available to the compiler to finish the job. Attached Image(s) |
|
|
|
只有小组成员才能发言,加入小组>>
5161 浏览 9 评论
1999 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3171 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
731浏览 1评论
613浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
503浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
629浏览 0评论
527浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 23:14 , Processed in 1.164010 second(s), Total 82, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号