PDA

View Full Version : PBP instruction clock cycles



MOUNTAIN747
- 31st January 2009, 00:47
Would someone please give me your best guess for the number of clock cycles from the first Port read to and including the second Port read of the following instructions. I am trying to checking an input for a hall effect sensor looking at a rotating notched disk and would like to know the time between input reads as to make needed adjustments. I have never seen a list of PBP instruction clock cycles for simple instructions.
Thanks: Mountain

IF PortC.4=1 THEN
Avar=1
Else Avar=0
Endif

IF PortC.4=1

Darrel Taylor
- 31st January 2009, 02:16
Guessing not required.
You can measure it.

instruction execution time
http://www.picbasic.co.uk/forum/showpost.php?p=1272&postcount=2

Darrel Taylor
- 31st January 2009, 02:30
Oh, forgot to mention ...

Changing

IF PortC.4=1 THEN

-- to --

IF PortC.4 THEN

will reduce it considerably.

With IF PortC.4=1, it places the value of the BIT in a temporary WORD sized variable, then calls a PBP library function that compares the whole word.

With IF PortC.4, it's 2 instructions (btfss/goto).
This only works with BIT vars.
<br>

MOUNTAIN747
- 31st January 2009, 02:41
Thanks Darrel, that’s great. What is the effect of the underbar preceding picOSC in line one? I looked through the PBP manual but didn't see anything about an underbar. Did I miss it? I'll save your post link for future reference. Thanks again!
Mountain

Darrel Taylor
- 31st January 2009, 02:53
In assembly, there are a lot of names already used, many of them are even single letters. Since you can't reuse variable names that are already in use, PBP places an underscore in front of all variables declared in your program to eliminate possible contentions.

While working in PBP those underscores are transparent, because PBP adds them when needed. But at the ASM level, you have to add the underscore to the PBP variable name to be able to access it.

In the case of _PicOSC, it just retrieves the value of the DEFINE OSC XX for use in calculating the amount of time used by the statements.
The OSC value is not directly available in PBP.


Did I miss it?
Section 8.2 Programming in Assembly Language
Page 180 in the latest manual.

hth,