完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我使用的是一个方便的交换机CASE汇编宏,它是通过将当前的测试值与当前实例的XOR一起进行测试,并且测试为零:“Switter”宏只是将汇编器变量“PREVTEST”初始化为零,并将CASE宏更新PREVTEST调用到经过的论证中。T的值,为下一个case语句设置。到目前为止,它一直在为我工作,这里的组装正确:四个文字参数的值是0x74、0x72、0x72和0x66。您可以看到,每个XOR的文字是XORY语句与当前语句的文字的结果。现在,我在同一个程序中的其他地方调用相同的宏,并且由于某些原因,汇编变量VestToT似乎没有得到更新:这里是文字参数。值是0x71,0xe1和0xe2,您可以看到这些值出现在XOR指令中,而没有与前一个调用的值进行XOR。宏中的汇编器“^”(XOR)运算符没有执行,或者PREPTEST的值为0。但它是相同的宏定义,在程序的其他地方工作!唯一的区别是工作和非工作调用在不同的部分,但这两个部分都具有相同的属性。我尝试使用.SET和=汇编操作符,并且我尝试了替代和AG&AMP格式作为参数引用,没有用。是的,我知道有很多。我可以用其他方法来实现这个代码,但是我想知道这里发生了什么,如果有人有任何想法的话。谢谢)
以上来自于百度翻译 以下为原文 I'm using a handy switch-case assembler macro that works by XOR'ing the previous case's test value with the current instance's, and testing for zero: .macro switch .equ prevtest,0 .endm .macro caseb value,dest xor.b value^prevtest,w0 bra z,dest .equ prevtest,value .endm The "switch" macro just initializes the assembler variable "prevtest" to zero, and invocations of the case macro update prevtest to the passed argument's value, setting it up for the next case statement. It's been working a treat for me until now, and here it's assembled correctly: 3367: GOTCOMMAND: 012DC0 BFCAE3 MOV.B 0xAE3, WREG 3368: mov.b RXTYPE,wreg 3369: switch 012DC2 B2C740 XOR.B #0x74, W0 3370: caseb #cmd_SPIN,DOSPIN 012DC6 B2C060 XOR.B #0x6, W0 3371: caseb #cmd_NEWSCHED,ERASESCHED 012DCA B2C010 XOR.B #0x1, W0 3372: caseb #cmd_SCHEDDATA,DOSCHEDDATA 012DCE B2C150 XOR.B #0x15, W0 3373: caseb #cmd_FINISHSCHED,DOFINISHSCHED The values of the four literal arguments are 0x74, 0x72, 0x73, and 0x66. You can see that the literal of each XOR is the result of XOR'ing the previous statement's literal with the current one's. Now I'm invoking the same macro elsewhere in the same program, and for some reason the assembler variable prevtest doesn't appear to be getting updated: 884: BL_GOTCOMMAND: 000260 BFCAE3 MOV.B 0xAE3, WREG 885: mov.b RXTYPE,wreg 886: switch 000262 B2C710 XOR.B #0x71, W0 887: caseb #cmd_GET,BL_DOGET 000266 B2CE10 XOR.B #0xE1, W0 888: caseb #cmd_ERASEFW,BL_ERASEFW 00026A B2CE20 XOR.B #0xE2, W0 889: caseb #cmd_WRITEFW,BL_WRITEFW Here the literal argument values are 0x71, 0xE1, and 0xE2 and you can see those values appear in the XOR instructions without having been XOR'd with the previous invocation's value. Either the assembler "^" (xor) operator in the macro is not being executed, or the value of prevtest is 0. But it's the same macro definition that works elsewhere in the program! The only difference is that the working and non-working invocations are in different sections, but both sections have the same attributes. I tried using .set and = assembler operators, and I tried the alternative &arg& format for the argument reference, to no avail. Yes, I know there are lots of other ways I can implement this code, but I'd like to know what's going on here, if anyone has any ideas. Thanks :) |
|
相关推荐
19个回答
|
|
|
我怀疑这是一种bug。你不需要做XORIN。PIC24具有“CP”命令,您可以使用它而不必担心先前的值。
以上来自于百度翻译 以下为原文 I suspect this is some sort of a bug. You don't need to do the xoring. PIC24 has the "cp" command, which you can use without worrying about previous values. |
|
|
|
|
|
谢谢。是的,我知道CP指令——就像我说的,我知道还有很多其他方法来实现这一点。然而,使用CP代替XOR,每case语句需要多条指令。
以上来自于百度翻译 以下为原文 Thanks. Yes, I'm aware of the cp instruction - like I said, I know there are lots of other ways to implement this. Using cp instead of xor, however, takes one more instruction per case statement. |
|
|
|
|
|
你能发布一个演示它的最小可编译代码吗?
以上来自于百度翻译 以下为原文 Can you post a minimal buildable code that demonstrates this? |
|
|
|
|
|
HM,这本身就是一个项目,我怀疑这个问题可能不会显现出来,因为宏在5000 +线计划的其他地方运作良好。让这个项目工作不是问题,这是我现在的首要任务。然而,汇编程序不能被信任的想法,动摇了我的世界的基础,我同意做一个更小、可重复的测试案例来证明这个问题对于跟踪它是很重要的。我使用ASM30超过10年,从未见过它做任何阴险的事情。
以上来自于百度翻译 以下为原文 Hm, that would be a bit of a project in itself and I suspect that the issue might not manifest itself, given that the macro works fine elsewhere in this 5,000+ line program. Getting this program to work is not a problem, and that has to be my priority right now. The idea that the assembler can't be trusted, though, rocks the foundations of my world,, and I agree that making a smaller, repeatable test case demonstrating the issue will be important in tracking it down. I've used ASM30 for over 10 years and never seen it do anything this insidious. |
|
|
|
|
|
不,它是完全相同的-CP/BRA,而不是XOR/BRA。
以上来自于百度翻译 以下为原文 No, it is exact the same - cp/bra instead of xor/bra. |
|
|
|
|
|
同意这一点需要跟踪。同时,使用CP作为诺斯盖尔建议:
以上来自于百度翻译 以下为原文 Agree this needs to be tracked down. In the meanwhile, use CP as NorthGuy suggested: .macro caseb value,dest cp.b w0,value bra z,dest .endm |
|
|
|
|
|
不,它是完全相同的-CP/BRA,而不是XOR/BRAR。不,不完全一样。纯文本的CP Reg仅为γLIT5。如果你需要更长的文字,你必须每次用文字加载W0,并与文件寄存器.CP.B进行比较,Fit不是什么大问题,但是主要的问题是能够信任汇编程序。
以上来自于百度翻译 以下为原文 No, it is exact the same - cp/bra instead of xor/bra. No, not exactly. CP reg with literal only goes to #lit5. If you need longer literals you have to load w0 with your literal each time and compare with a file register. cp.b, f It's not a big deal, but again, the major issue is being able to trust the assembler. |
|
|
|
|
|
|
|
|
|
|
|
你使用的是XC16版本?你最近更新了吗?在V1.25之后,我的一堆东西停止了像这样奇怪的事情。与V1.26发生了巨大变化,并且还没有被修复为V1.31。
以上来自于百度翻译 以下为原文 What version XC16 are you using? Did you recently update? After v1.25, a bunch of my stuff stopped working with odd things like this. Something massively changed with v1.26, and has not yet been fixed as of v1.31. |
|
|
|
|
|
很高兴知道,谢谢,但是我在这个项目的24F。
以上来自于百度翻译 以下为原文 Good to know, thanks, but I'm in a 24F on this project. |
|
|
|
|
|
我用1.30,自从2月22日发布,是的,我想我最近必须更新:我会尝试1.25,看看它是否有效,谢谢!
以上来自于百度翻译 以下为原文 I'm using 1.30, and since that was released Feb 22, yeah, I guess I must have updated recently :) I'll try 1.25 and see if that works, thank you! |
|
|
|
|
|
也许这样的事情可以奏效:
以上来自于百度翻译 以下为原文 Perhaps something like this could work:.macro switch #undef prevtest #define prevtest 0 .endm .macro caseb value,dest xor.b value^prevtest,w0 bra z,dest #undef prevtest #define prevtest value .endm |
|
|
|
|
|
对于较长的文字,你可以使用“子”,目的是在[W15] -XC16这样做。编辑这是错误的,它也是唯一的一个LIT5:)在信任汇编程序时,我发现了很多错误,特别是IRP如何工作以及它如何与宏交互。我只使用任何工作,避免任何东西。但是,我仍然使用MPLAN 8.92作为PIC24汇编程序。
以上来自于百度翻译 以下为原文 For longer literals you can use "sub" with the destination in [w15] - XC16 does this. As to trusting the assembler, I found lots of bugs in it - in particular with how .irp works and how it interacts with macros. I just use whatever works and avoid what doesn't. However, I still use MPLAN 8.92 for PIC24 assembler. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
你能用这个替换XOR行并发布反汇编吗?或者这个我想看看PREPTEST的值。
以上来自于百度翻译 以下为原文 Can you replace the XOR line with this and post the disassembly: xor.b value ^ value ^ prevtest,w0 or this xor.b #prevtest ^ value ^ value,w0 I want to see the values of prevtest. |
|
|
|
|
|
我对每一个CASeB调用进行伪装。每次预防试验=0。
以上来自于百度翻译 以下为原文 I put mov #prevtest,w1 after every caseb invocation. prevtest = 0 every time. |
|
|
|
|
|
你能告诉我们你使用的PIC24F的零件号吗?
以上来自于百度翻译 以下为原文 Could you tell us the part number for the PIC24F you are using? |
|
|
|
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
494 浏览 0 评论
5807 浏览 9 评论
2347 浏览 8 评论
2235 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3542 浏览 3 评论
1150浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1117浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
884浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
495浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-10 23:17 , Processed in 1.176757 second(s), Total 110, Slave 93 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
4218