I seem to having endless problems with this simple instruction.
If I have the following code:
movlw b'00000000'
btfsc W, 0
goto Intrusion
goto Main
According to the datasheet - btfsc: If bit is set then skip next instruction. On the above bit zero is clear so it should execute the next instruction. Why's it that my mode keeps jumping to Main
I seem to having endless problems with this simple instruction.
If I have the following code:
movlw b'00000000'
btfsc W, 0
goto Intrusion
goto Main
According to the datasheet - btfsc: If bit is set then skip next instruction. On the above bit zero is clear so it should execute the next instruction. Why's it that my mode keeps jumping to Main
You need to try reading the datasheet! - BTFSC can't be used on the W register, only on file registers - the only reason it assembles OK is that W is in the include file as a destination.
Thanks - that might explain why I was having trouble
I've done a search through the 16F62X datasheet and under the BTFSC instruction it doesn't mention anything about not using the W register. Unless of course I'm not reading it correctly, which by this stage anything is possible. <grin>
Thanks - that might explain why I was having trouble
I've done a search through the 16F62X datasheet and under the BTFSC instruction it doesn't mention anything about not using the W register. Unless of course I'm not reading it correctly, which by this stage anything is possible. <grin>
It's in a section for action only on file registers - W is defined in the include file as either 0 or 1 (can't remember which as you never need to know). So your line actually read:
Or just copy W to a file register, and check that - this doesn't alter the W register.
Using ANDLW is really a 'non-PIC' method though, most processors don't have bit-wise instructions, and logical operations on the entire byte are the only way to test, or modify, individual bits. PIC's are designed for low level operations, and thus have bit-wise operators - you may as well use them?.