----- Original Message ----- From: Drew Vassallo To: Sent: Thursday, January 04, 2001 10:45 PM Subject: Re: [PIC]: Not use the address but what is inside that address > The original problem was: > > > > Petra: I should use any port, and any bit... my idea is to make a > > > subrutine to read a bit using sofware filter... > > How is the routine below solving this problem? It looks useful for DEFINING > a bit to output, not reading a bit in. Oops, sorry -- lost track of the original request. Here is the code to check a bit: ; To test bit "BitNum" or port "PortNum" movf PortNum,W movwf FSR movf BitNum,W call BitToMask andwf INDF,W ; At this point Z is set if PortNum,BitNum was clear ; Z is clear if PortNum,BitNum was set Bob Ammerman RAm Systems (contract development of high performance, high function, low-level software) > >You need to map from a bit number to a bitmask, then use logical > >instructions: > > > >To turn on bit "BitNum" of port "PortNum": > > > > movf PortNum,W > > movwf FSR > > > > movf BitNum,W > > call BitToMask > > iorwf INDF,F > > > >To turn off bit "BitNum" of port "PortNum": > > > > movf PortNum,W > > movwf FSR > > > > movf BitNum,W > > call BitToMask > > xorlw 0xFF > > andwf INDF,F > > > > > >BitToMask: > > addwf pcl > > retlw 1 > > retlw 2 > > retlw 4 > > retlw 8 > > retlw 16 > > retlw 32 > > retlw 64 > > retlw 128 -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.