Hi, Somasundaram -----Original Message----- From: Somasundaram To: PICLIST@MITVMA.MIT.EDU Date: Saturday, October 16, 1999 2:30 PM Subject: BTFSS help >Hi, > >I am a PIC newbie. I am working on 16f877. I use MPLAB 4.12 for Windows. > >I have a value stored in the FileRegister 0x27 < General Purpose Register>. >That value is always between 0 and 7 (both inclusive). This value will >be dynamically varying during program execution. I need to use this value >in the instruction BTFSS. How do I use it as required? Are there any other BTFSS is required to have a constant bit position. But you can try reprogramming the instruction at run-time (takes some time :) >methods that can be used to skip instructions based on a bit, with the bit >position dynamically varying during program execution? > There are no one-instruction way to check a bit with a variable position. Try these methods: Method 1: Rotate the register you are checking several times, till the bit in question will be copied to carry bit in STATUS. Then simply check carry. Method 2: Make a look-up table with 8 entries. Each entry will contain mask X depending on a bit position N, which is also address to the table. (X = 2 ^ N) When you need to check a specific bit, find the corresponding mask, AND the mask with the register you are checking. Then check zero bit. z = 1 if bit N = 0, z = 0 if bit N = 1. Method 3: Keep additional variable that contains dynamically changing mask. Then apply the mask when needed. I hope it helps.