完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,在研究谷歌之后,在XC32指南上,我放弃并问:ASM(“…”)和ASM易失性(“…”)之间的区别是什么?而且,ASM和γ-ASMY之间有什么区别吗?谢谢你,M.R.
以上来自于百度翻译 以下为原文 Hi, after research on Google and on the XC32 Guide, I give up and ask here. What is the difference between asm("...") and asm volatile ("...") ? And, is there any difference between asm and __asm__ ? Thank you. M.R. |
|
相关推荐
7个回答
|
|
没有区别。易失性限定符是可选的,并且没有影响,因为所有的ASM块都是隐式的易失性。当编写可以用ANSI(或X-32中的-FNOM ASM)编译的代码和各种STD选项时,使用Y-asASMY代替ASM,其中关键字ASM、内联和Type不被识别为关键字,因此代码可以使用这些词作为标识符。
以上来自于百度翻译 以下为原文 No difference. The volatile qualifier is optional and has no effect, as all asm blocks are implicitly volatile. When writing code that can be compiled with -ansi (or -fno-asm in XC32) and the various -std options, use __asm__ instead of asm, where the keywords asm, inline, and typeof are not recognized as keywords, so that code can use these words as identifiers. |
|
|
|
嗨,上面的一些问题在GCC文档中得到回答:HTTPS://Gcc.GNUGOR/ONLIDEOCS/GCC/ExtDeD-ASM.HTMLASM和Y-AASMYI以相同的方式工作,但是这两种形式都是标准化C语言定义的扩展。因此,在严格解释C语言规则时,ASM应该是变量的名称,或者ASM(…)可以调用的函数的名称。如果使用更严格的语言标准选项编译,如-ANSI或-STD=……,它们仍然会被接受。在编译器命令行中。迈西尔
以上来自于百度翻译 以下为原文 Hi, Some of the questions above are answered in GCC documentation: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html asm and __asm__ work the same way, but both forms are extensions to the standardized C language definitions. In C language, there is a set of keywords that have defined meaning in the language, and asm is not one of those. So in strict interpretation of C language rules, asm should be the name of a variable, or asm(...) the name of a function that may be called. Keywords with double underscore: __something or __something__ is a way of using features of the compiler, without breaking language rules. They will still be accepted if compiled with more strict language standard options, like -ansi or -std=... in compiler command line. Mysil |
|
|
|
没有区别。易失性限定符是可选的,没有影响,因为所有的ASM块都隐含地是不稳定的。不正确。ASM(“…”)语句的内容在优化和最终汇编之前只与编译器*的输出对齐。易失性被用来提示优化代码可能有副作用,以防止它被优化。注意,除非使用NoeReald/RealDead汇编器指令,您的优化优化的ASM代码*将被优化器所困扰。
以上来自于百度翻译 以下为原文 No difference. The volatile qualifier is optional and has no effect, as all asm blocks are implicitly volatile. Not correct. The contents of the asm("...") statement are pretty much just inlined with the output of the compiler *before optimisation and final assembly*. The volatile is used to hint to the optimiser that the code may have side effects, to prevent it being optimised away. Note that unless you use the .noreorder/.reorder assembler directives, your nicely optimised asm code *will* be messed with by the optimiser. |
|
|
|
你说得对。当我张贴时,我在想,因为我似乎记得在这里阅读优化器可以弄乱汇编代码。
以上来自于百度翻译 以下为原文 You're correct. I was thinking of that when I posted, as I seem to recall reading here that the optimizer can mess with the assembly code. |
|
|
|
谢谢你的回复。是否有汇编指令的内联C?或者我应该简单地总是指定ASM的易失性(因为我不希望我的内联ASM被优化器改变)?干杯。
以上来自于百度翻译 以下为原文 Thank you for all your replies. Is there a inline C equivalent of the assembler directives .noreorder/.reorder ? Or should I simply always specify volatile with asm (as I don't want my inline asm to be changed by the optimizer)? Cheers. |
|
|
|
我不知道这是否可行;
以上来自于百度翻译 以下为原文 I wonder this might work #define asm(x) asm volatile(x) ;) |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5170 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
736浏览 1评论
619浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
507浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
633浏览 0评论
530浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 12:08 , Processed in 1.468152 second(s), Total 91, Slave 74 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号