完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
伙计们,我确信这是一个愚蠢的问题,但是我认为有一种方法可以使编译器预做数学与#define语句相关联。例如:#define x 10#define y(adder)(x+adder)C code:dummy=y(50)编译器将预添加x(10)+50。所以MCU执行的实际代码是dummy=60,而不是dummy=10+50我希望这是有意义的。
以上来自于百度翻译 以下为原文 Guys I am sure this is a silly question, but I thought there was a way to make the compiler pre-do math associated with #define statements. for instance: #define x 10 #define y(adder) (x+adder) C code: dummy = y(50) Where the compiler would pre-add the x(10) + 50. So the actual code executed by the MCU is dummy = 60 instead of dummy = 10 + 50 I hope that makes sense. Thanks in advance, Dave P |
|
相关推荐
3个回答
|
|
|
|
|
|
我相信多年前,当我真正读到文学作品时,它说它会,但我很好奇,如果我必须为此设置任何选项。我想我可以只对它进行编码,然后看看拆卸列表。但是如果它不做我所期望的,我应该做什么设置来实现这一目标呢?
以上来自于百度翻译 以下为原文 I believe years ago when I actually read the literature that it said it would but I was curious if I have to set any options to do so. I guess I can just code it, then look at the disassembly listing. But it if does not do what I expect, what settings should I do to make that happen? |
|
|
|
也许我只是过度的资源意识,但我的问题背后的想法是尽可能地优化。这个例子“哑=50 +X”只是一个基本的例子。在现实世界中,我想计算一组索引,如果有的话,这些索引可能变化甚微。它将在程序时间内改变,而不是运行时。如果它改变了,我希望它在引用的地方动态地改变。为了限制开销和浪费的MCU内存,最好让编译器进行预计算,这样CPU就不必再进行其他添加,或者在运行时预计算一次索引并将其存储在RAM中的情况下使用额外的ram。
以上来自于百度翻译 以下为原文 Maybe I am just over-resource conscious, but the idea behind my questions is to optimize as much as possible. The example "dummy = 50 + x" was just a basic example. In the real world case I want to calculate a set of indexes that may change very little if ever. It would be changed during program time, not run-time. If it does change I want it to change dynamically everywhere they are referenced. To limit both overhead and wasted MCU memory it would be nice to have the compiler pre-calculate so that the CPU doesn't have to do yet another add, or use extra ram in the case where this index would be pre-calculated once at run time, and stored in RAM. |
|
|
|
只有小组成员才能发言,加入小组>>
5195 浏览 9 评论
2013 浏览 8 评论
1937 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3185 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2240 浏览 5 评论
751浏览 1评论
637浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
522浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
648浏览 0评论
549浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-2 20:38 , Processed in 1.383724 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号