On Thu, 18 Nov 1999 06:56:49 +1100 Agnes en Henk Tobbe writes: >I tried the following to see if the reslt of a substraction was >negative... >movf test, w >sublw 0x0x >btfss w, 7 ; see if the MSB in W is set >do this >do that > >but it did not work...... >what works is >after the substraction > >movwf temp >btfss temp, 7 >di this >do that > >Can anyone tell how come? Cannot bits in W be tested? > On most PICs, the W register is not in the "file register" map, so "F" instructions such as btfss do not work. The 17c and 18c processors have wreg, which IS in the file register map, so you can use these instructions there. Note that "w" is 0 and "f" is 1 in the processor include files so you can use them as the destination bit in instructions that take a destination bit. Finally, with the SUB instructions on a PIC, you can check for a negative result by checking the carry bit of the status register. The bit is set if the result of the subtraction was positive and clear if the result was negative. Harold Harold Hallikainen harold@hallikainen.com Hallikainen & Friends, Inc. See the FCC Rules at http://hallikainen.com/FccRules and comments filed in LPFM proceeding at http://hallikainen.com/lpfm ___________________________________________________________________ Get the Internet just the way you want it. Free software, free e-mail, and free Internet access for a month! Try Juno Web: http://dl.www.juno.com/dynoget/tagj.