piclist 1999\10\31\213701a >
Thread: Direct, Indirect when referencing BTFSC FILE, BIT
www.piclist.com/techref/index.htm?key=direct+indirect
flavicon
face BY : Dennis Plunkett email (remove spam text)



At 12:13 1/11/99 +1100, you wrote:
{Quote hidden}

I realy can't see what is going on here,
If you are decementing to see what the results is you can have either a 1
or a 0, no matter what.
Or is it that you are trying to use this as a mask for testing of each
potential bit location.
Ah yes the latter
If the latter is true, then there is the problem in that the compiler +
opcodes expect this to be a litteral value, hence the method used by Tony.

E.G BTFSC myval, 0-7, where the 0 to 7 are fixed.

If this is the case then perhaps you could waste a bit of space
and use a table type function

                                       ;Test byte is the location to be compare
d with the counter
                                       ;value. This makes the code resuable for
testing of bit
                                       ;compares for any direct RAM location
               movf    PORTB
               movwf   test_byte,w     ;do this bit on pre entry

               counter         ;the current bit location to look at
                                       ;the counter is 0-7 and indicates the bi
t that we want to look
                                       ;at. Note that this vale must be preload
ed and maintained by
                                       ;the calling code

                                       ;function body


;***********
bit compare:
;***********
;                                       Perequsites
;                                       ===========
;                                       Counter must be set with the bit to test
;                                       w must contain the table offset
;                                       test_byte must be the byte to test to
;                                       LOCAL variable  :- test_byte -> effectiv
e only, not to be preserved

               movlw   3               ;so that we get to the correct location
in the table
               addw    counter
               add     pcl,w           ;point to the location to jump to
TABLE
               nop
               nop
               nop
               btfsc   test_byte,0
               goto    return_true
               goto    return_false
               btfsc   portb,1
               ...

return_true
               do stuff

return_false
               do other stuff

I know that there is stuff missing in the table but you can get the general
idea. Tonys stuff also works, but
resides on the assumption that the value (As you requested) is dectmented
by one each time, where the table value lets you attack any bit at any time.

On further thinking Tonys way on bit test will work at all times, so ignore
the rubbish I just came up with

Dennis

<3.0.32.19991101134158.006d60d8@huey>

See also: www.piclist.com/techref/index.htm?key=direct+indirect
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Direct, Indirect when referencing BTFSC FILE, BIT

month overview.

new search...