完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
PIC16F8MPLAIDID892汇编是初学者发现PIC编程的秘密,但我理解这个命令子问题有一个问题,因为我在模拟时得到了不一致的结果。我的代码:列表P= 16F88,包括P16F88C MOVLW D’0’子’D’0最终结果是D’25’!为什么?因为0 - 0不能D’25’!它是一个价值,我将放在W,或它的价值。结果对于第一次使用值25总是不正确的。但是,当第二次和下一次重复命令时,结果会减去O’1’。我犯了什么错误?谢谢你的时间。
以上来自于百度翻译 以下为原文 PIC 16F88 MPLAB IDE 8.92 Assembler I'm a beginner who discovers the secrets of PIC programming. But I have a problem understanding this command SUBLW, because I get the incorect results when simulating. My code: LIST P=16F88 #include p16f88.inc movlw d'0' sublw d'0' END Result is d'25'! Why? Because 0 - 0 can not be d'25'! It is one which value I will put in W, or what value it literal. The result is always incorrect for the first use of the value 25 .. But when the second and next repeats the command decreases the result o d'1'. Where am I making a mistake? Thx for your time. |
|
相关推荐
4个回答
|
|
您的错误是允许程序运行结束指令。在结束指令之前进行调解。
以上来自于百度翻译 以下为原文 Your mistake is allowing the program to run past the END directive. Add goto $ immediately before the END directive. |
|
|
|
谢谢你的回复,我不明白我的错误的原因。但是你的建议是有效的。数据表说明这个指令需要1个周期。因此,下一步应该是结束指令。程序如何允许TROUN通过结束指令?如果问题太广泛,你就不必向我解释了。我稍后会发现,在“发现秘密”的照片。我希望……非常…
以上来自于百度翻译 以下为原文 Thank you for your response. I do not understand the cause of my mistake. But your recommendation works. The data sheet states that this instruction will take 1 cycle. So, the next step should be the END instruction. How is the program allowed to run past the END instruction? If the problem is too extensive, you do not have to explain it to me. I'll find out later, during the "discovers the secrets" of the PIC. I hope... Very thx... |
|
|
|
在MPLAB8中,单击View & GT;观察打开窗口,并添加WReg。单击View & Gt;程序内存打开程序内存窗口。单击Bug ALL来组装程序。单击步骤执行MOVLW指令和WReg=0。Click Step Into再次执行该指令,但请执行。注意,在程序内存窗口中,它执行到第1002行和WRG=25。结束指令不是指令。它告诉汇编程序一个生成的结束。在程序存储器窗口中通知未编程的内存位置都是1位。对于14位PIC16指令,它是OpCal码0x3FFF,它恰好是汇编指令ADLW 255。记住第二步执行1000个指令(一个下位和999个ADDLW),并在第1002行停止;不要问我为什么1000,这是MPLAB模拟器的一个怪癖。不管怎样,在WRGG=0+999×255=0x3E319的情况下,加入WRG=0的999倍的结果是255。由于WREG是一个8位寄存器,下字节0x19=25十进制。现在,单击一步执行一个未编程的程序存储器,WRG减量1。这是因为AdDLW 255与8位值的AdDLW 1相同。这里的PIC设备不停止运行,因此您必须将代码放在一个循环中,例如Goto $分支到自身——无限循环。在实际的嵌入式应用程序中,代码通常在主循环中执行指令。
以上来自于百度翻译 以下为原文 In MPLAB8,
The END directive is NOT an instruction. It tells the assembler the end of a build. Notice in the Program Memory window that unprogrammed memory locations are all 1's. For a 14-bit PIC16 instruction that is opcode 0x3FFF which happens to be the assembly instruction ADDLW 255. Remember the second Step Into executed 1000 instructions (one SUBLW and 999 ADDLW) and halted at line 1002; don't ask me why 1000, that is a quirk of the MPLAB Simulator. Anyway, adding 999 times of 255 to WREG = 0 results in WREG = 0 + 999*255 = 0x3E319. Since WREG is an 8-bit register the lower byte 0x19 = 25 in decimal. Now, clicking Step Into each time executes one unprogrammed program memory and WREG decrements by 1. That is because ADDLW 255 is same as ADDLW -1 for an 8-bit value. Lesson here is the PIC device does not stop running, so you will have to put your code in a loop; e.g. GOTO $ which branches to itself -- an infinite loop. In a real embedded application your code generally executes instructions in a main loop. |
|
|
|
非常感谢你的帮助!现在一切都清楚了。我想我们再看一看我的其他NoOB的问题。或不是?咧嘴笑:
以上来自于百度翻译 以下为原文 Thanks so much for your help! Everything is clear for now. I think we're going to have another look at my other noob's questions. Or not? grin: |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
774浏览 1评论
664浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
592浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
674浏览 0评论
574浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-22 20:58 , Processed in 1.297836 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号