Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

PIC Assembly: BTFSC and BTFSS

Status
Not open for further replies.

T3STY

Full Member level 4
Joined
Apr 17, 2012
Messages
239
Helped
24
Reputation
48
Reaction score
24
Trophy points
1,308
Activity points
3,715
I tried but I actually didn't really understand how BTFSC and BTFSS instructions work. The manual syntax and description are:
BTFSC f,b
If bit ’b’ in register ’f’ is ’1’, the next instruction is executed. If bit ’b’ in register ’f’ is ’0’, the next instruction is discarded, and a NOP is executed instead, making this a 2TCY instruction.
BTFSS f,b
If bit 'b' in register 'f' is '0', the next instruction is executed. If bit 'b' is '1', then the next instruction is discarded and a NOP is executed instead, making this a 2TCY instruction
What I didn't understand is what the heck should the b value do. As from the name (Bit Test File Skip Clear/Set) the instruction should check if the specified file f is set or clear and if it's set (BTFSS) or clear (BTFSC) skip next instruction.
So, what does this b bit do exactly?
 

keith1200rs

Super Moderator
Staff member
Joined
Oct 9, 2009
Messages
10,877
Helped
2,064
Reputation
4,128
Reaction score
1,597
Trophy points
1,403
Location
Yorkshire, UK
Activity points
57,276
It is a BIT test so you are testing, for example whether the 5th bit of a file/register is 1 or 0. So in that case the b would be 5.

Does that make sense?

Keith
 
  • Like
Reactions: T3STY

    T3STY

    points: 2
    Helpful Answer Positive Rating

T3STY

Full Member level 4
Joined
Apr 17, 2012
Messages
239
Helped
24
Reputation
48
Reaction score
24
Trophy points
1,308
Activity points
3,715
Oh.. yup, it does make sense now.
What if I wanted to test the whole file, should I go through all the bits of it or is there any other faster way that does that in one move?
 

dustie

Newbie level 6
Joined
Oct 2, 2009
Messages
11
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Macedonia
Activity points
1,353
Well, in that case (if you want to test the whole byte) it would be better to subtract a certain number (in binary form, of course) from the byte you want to test.
If the result is zero (chech the STATUS,Z control bit) than the byte you are testing is equal to the one that is used as a subtractor.
 
  • Like
Reactions: T3STY

    T3STY

    points: 2
    Helpful Answer Positive Rating

T3STY

Full Member level 4
Joined
Apr 17, 2012
Messages
239
Helped
24
Reputation
48
Reaction score
24
Trophy points
1,308
Activity points
3,715
Oh, right! I remember now that I've also seen some code somewhere on the forum, that moved the file on itself whilst triggering Z when 0, I've got to look for that.
Thanks!
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top