SetBit, ClearBit and TestBit

General discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
qbasic
Posts: 69
Joined: 21 Aug 2012 07:28
Location: Italy

SetBit, ClearBit and TestBit

#1 Post by qbasic » 14 Sep 2020 21:55

Hi all.
Just a simply question, please.

In your opinion is better to use

Code: Select all

SetBit(PORTB, 2)
ClearBit(INTCON, RBIF)
if TestBit(INTCON, INTE)...
or simply statement

Code: Select all

PORTB.2 = 1
INTCON.RBIF = 0
if INTCON.INTE = ...
?
Thanks

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: SetBit, ClearBit and TestBit

#2 Post by janni » 15 Sep 2020 00:31

Theoretically, use of the pseudo-routines should ease porting to another compiler. In practice, SetBit and ClearBit are identical in final (assembly) code to straight bit assignments but situation is different with TestBit. When used in a conditional statement it will unnecessarily bloat final code .

qbasic
Posts: 69
Joined: 21 Aug 2012 07:28
Location: Italy

Re: SetBit, ClearBit and TestBit

#3 Post by qbasic » 15 Sep 2020 00:51

So, in a conditional statement is better NOT used the pseudo-routines meneawhile for assignment is indifferent, is right ?

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: SetBit, ClearBit and TestBit

#4 Post by janni » 15 Sep 2020 01:32

qbasic wrote:
15 Sep 2020 00:51
So, in a conditional statement is better NOT used the pseudo-routines meneawhile for assignment is indifferent, is right ?
Right.

Post Reply

Return to “mikroBasic PRO for PIC General”