>At 01:38 PM 8/12/00 -0700, you wrote:
>>Hi,
>>This my second program on a PIC. I'm using a 16F877 and having
>>some trouble getting the right value into w.
>>
>>Tthis starts with a value already in w such as 'a'.
>>If w = 'a', I want to replace it with 'x'
>>If w != 'a' leave as is.
>>The trouble is the last instruction, movlw _w puts 0x21 into w.
>>I set a watch on w and _w and all looks good until the last instruction.
>>This is probably something elementary but it's got me stuck.
>>Appreciatte any help.
>>
>> movwf _w ;save w
>> xorlw 0x61 ;compare w to 'a'
>> btfss status,2
>> goto send
>> movlw 0x78 ; x
>> movwf _w ;restore w with orig or new char
>>
>>send
>> movlw _w
>>
>
>As written here, "movlw" command means "move literal to w",
>where literal = an 8-bit constant. 0x21 is probably the
>address of your variable _w.
>
>BTW, just a hint - it usually makes code more readable if
>you write
>
>"btfss status,Z" rather than "btfss status,2"
>
>Also, some people write
>
>"movf _w,0" and "movf _w,1" whereas
>
>"movf _w,w" and "movf _w,f" are much more readable.
>
>best regards,
>- danM
>
>--
>
http://www.piclist.com hint: The PICList is archived three different
>ways. See
http://www.piclist.com/#archives for details.
>