Main:
MOVLW D'4'
MOVWF EXAMPLE
MOVF EXAMPLE,W
CALL TABLE
GOTO $
;ORG 0x0200
TABLE
ADDWF PCL,F
RETLW H'01'
RETLW H'02'
RETLW H'03'
RETLW H'04'
; *** main code goes here ***
如果ORG 0X0200注释掉,程序就工作很正常,为什么加上去后,PC在ADDWF PCL,F后就乱跳了呢?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
The contents of PCLATH and PCLATU are transferred
to the program counter by any operation that writes to
PCL. Similarly, the upper 2 bytes of the program
counter are transferred to PCLATH and PCLATU by an
operation that reads PCL. This is useful for computed
offsets to the PC (see Section 5.1.6.1 “Computed
GOTO”).
The PC addresses bytes in the program memory. To
prevent the PC from becoming misaligned with word
instructions, the Least Significant bit (LSb) of PCL is
fixed to a value of ‘0’. The PC increments by two to
address sequential instructions in the program
memory.
The CALL, RCALL, GOTO and program branch
instructions write to the program counter directly. For
these instructions, the contents of PCLATH and
PCLATU are not transferred to the program counter.
(原文件名:未命名.jpg)
上面不是说在读PCL的时候 PCLATH,PCLATU不是自动从PC更新过来吗?奇怪
;******************************************************************************
;Start of main program
; The main program code is placed here.
ORG 0x1000
TABLE
;ADDWF PCL
;MOVWF PCL,F
ADDWF PCL,F
RETLW H'0F'
RETLW H'0E'
RETLW H'0D'
RETLW H'0C'
RETLW H'0B'
RETLW H'0A'
RETLW H'09'
RETLW H'08'
RETLW H'07'
Main:
MOVLW H'10'
MOVWF PCLATH
MOVLW D'4'
CALL TABLE
GOTO $
一周热门 更多>