I have been reading various tutorials and datasheets but I seem to be blind to a very
basic concept that just eludes me.
Here is a bit of code taking a character from a Table for display to an LCD.
My question has to do with the instruction ADDWF
where tutorials give an example of:
MOVLW 1 ; put 1 in W
ADDWF temp,F ; add 1 to temp, store in temp
However, in the context below addwf does much more:
************************
Msg1 movlw high Msg1Ts ; Pick up high byte of table address
movwf PCLATH ; And save into PCLATH
movf MsgIdx,W ; Pick up index
addwf PCL,F ; And look up in table
Msg1Ts dt "TestMessage",0 ; Message, terminate with zero
****************************
If at the start of this subroutine, PCL = 0xA0 and MsgIdx =1...
In Debug, I would expect W to contain "PCL"+"1" which should mean W should contain 0xA1,
the sum. Instead, W contains the contents of address 0xA1, which happens to be the first
address of the table holding the ASCII value of the first table character.
How does the processor know when to interpret addwf as simple arithmetic of register
contents versus a pointer to a new address whose contents should be copied to W?
Must be an easy answer that I have just overlooked :-)
thanks
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )