完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
使用PIC24FJ256GB106XC161.31注意到下面的代码只在选择0到15之间时才工作,在费力地钻研汇编程序输出之前,我认为下面的快速修改将做出如下选择:UIT88TWDTEMP和DWMMUMASK都是UIT32在调试器中注意到的第二个帖子是,当ByBoice选择=16;DWTEMP= 0xFFFF 80SO 1 & lt;lt;16==0xFFFF 8000。???给出什么
以上来自于百度翻译 以下为原文 using a pic24fj256gb106 xc16 1.31 noticed that the following code appeared to only work when bySelection is between 0 and 15 if(((ptrMenu->dwMenuMask) & (1 << bySelection)) != 0) break; before bothering to dig into the assembler output i figured the following quick modification would do the trick dwTemp = (1 << bySelection); if(((ptrMenu->dwMenuMask) & dwTemp) != 0) break; bySelection is uint8_t dwTemp and dwMenuMask are both uint32_t From the second posting I noticed in the debugger that when bySelection = 16; dwTemp = 0xffff 8000 so 1 << 16 == 0xffff 8000 ??? what gives ! dwTemp = (1 << bySelection); 0x162B2: MOV.B [W14+16], W0 0x162B4: ZE W0, W0 0x162B6: MOV #0x1, W1 0x162B8: SL W1, W0, W0 0x162BA: ASR W0, #15, W1 0x162BC: MOV W0, [W14+10] 0x162BE: MOV W1, [W14+12] ! if(((ptrMenu->dwMenuMask) & dwTemp) != 0) 0x162C0: MOV [W14+14], W0 0x162C2: MOV [W0+768], W2 0x162C4: MOV [W0+770], W3 0x162C6: MOV [W14+10], W0 0x162C8: MOV [W14+12], W1 0x162CA: MOV W2, W4 0x162CC: MOV W3, W2 0x162CE: MOV W0, W3 0x162D0: MOV W1, W0 0x162D2: AND W4, W3, W4 0x162D4: AND W2, W0, W0 0x162D6: CLR W1 0x162D8: SL W0, #0, W1 0x162DA: MOV #0x0, W0 0x162DC: MOV.D W0, W2 0x162DE: MUL.UU W4, #1, W0 0x162E0: IOR W2, W0, W2 0x162E2: IOR W3, W1, W3 0x162E4: SUB W2, #0x0, [W15] 0x162E6: SUBB W3, #0x0, [W15] 0x162E8: BRA NZ, 0x162F8 ! break; |
|
相关推荐
3个回答
|
|
什么都定义为?int?你知道PIC24是一个16位CPU,而int是16位的吗?(0到15…)
以上来自于百度翻译 以下为原文 What is everything defined as ? int? You know that The PIC24 is a 16 bit CPU and ints are 16 bits for it? (0 to 15...) |
|
|
|
这些是C规则。“1 & lt;lt;b选择”的结果具有“签名int”类型。这里的结果是:所有的移位16或更多是未定义的,最终可能是任何东西。如果左操作数被签署并且可以是任何东西,15的移位也是未定义的。然而,它自然地在我所编写的所有编译器中产生0x8000。0x8000具有符号位集,因此它代表-32768。当你把它分配给32位变量时,你也得到-32768,它现在是0xFFFF8000。如果期望更长的结果,则将操作数转换为更长的类型,例如“1UL & lt;lt;副选择”。
以上来自于百度翻译 以下为原文 These are C rules. The result of "1 << bySelection" has the "signed int" type. Here's the consequences: All shifts by 16 or more are undefined and may end up being anything. Shift by 15 is also undefined if the left operand is signed and could be anything. However, it naturally yields 0x8000 in all compilers that I've seen. 0x8000 has the sign bit set, so it represents -32768. When you assign it to a 32-bit variable, you also get -32768, which is now 0xffff8000. All as expected. If you want longer results, cast operands to longer types, e.g. "1UL << bySelection". |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5160 浏览 9 评论
1998 浏览 8 评论
1927 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3170 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2225 浏览 5 评论
727浏览 1评论
612浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
501浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
626浏览 0评论
524浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 07:49 , Processed in 1.160827 second(s), Total 81, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号