Sign in

username:

password:



Not a member?

Search piclist



Search tips

Subscribe to piclist



piclist by Keywords

12F675 | 16F628 | 16F84 | 16f877 | 16F877A | 16F88 | 18F458 | ADC | AVR | Bootloader | CAN | CCS | CRC | EAGLE | EEPROM | ICD | ICSP | IDE | JDM | LED | Macros | Microchip | MPLAB | PCB-CAD | PIC10F | Pic12f675 | PIC16F84 | PIC16F84A | PIC16F877 | PIC18 | PIC18F452 | PicBasic | PICC | PICSTART | PWM | RS-485 | RS232 | SMT | SPI | UART | USART | USB | Wireless | Wisp628 | Xilinx

Ads

Discussion Groups

See Also

DSPFPGAElectronics

Discussion Groups | Piclist | Very Very Basic Question on PIC16 instruction


Advertise Here

A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.

Very Very Basic Question on PIC16 instruction - jsternmd - Aug 10 23:37:42 2009

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 )