I am not surprised that each line averages 800 uSecs. You have some pretty complex logic in those statements.
Have a look at the machine code listing the basic source produces and you will see just how many instructions are involved.
Also, you will find big differences in execution time for BYTE and WORD variables.
For example
A var byte
w var word
if a<9 then dosomething
runs much faster than
if w<9 then dosomething
For any realtime work I define a port as a diagnostic pin and make sure it is an output then check the execution time with an oscilloscope.
Diag var portb.0 (for example)
Trisb = %11111110 (or whatever)
Then before each program block I want to test for execution time I put
Diag = 1
Code to be tested goes here
Diag = 0
This runs a little faster than
HIGH Diag
Code goes here
LOW Diag
The oscilloscope is invaluable if you have a time critical application.
HTH
Brian
Bookmarks