在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,
- Click View > Watch to open the Watch window, and add WREG.
- Click View > Program Memory to open the Program Memory window.
- Click Build All to assemble your program.
- Click Step Into to execute the MOVLW instruction and WREG = 0.
- Click Step Into again to execute the SUBLW instruction, but notice in the Program Memory window it executes to line 1002 and WREG = 25.
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.
在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,
- Click View > Watch to open the Watch window, and add WREG.
- Click View > Program Memory to open the Program Memory window.
- Click Build All to assemble your program.
- Click Step Into to execute the MOVLW instruction and WREG = 0.
- Click Step Into again to execute the SUBLW instruction, but notice in the Program Memory window it executes to line 1002 and WREG = 25.
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.
举报