PDA

View Full Version : programming advice



thegoat001
09-17-2008, 06:21 AM
So I have about 1.5KB of code for my bs2sx and while I'm not really concerned about speed...I'm using two program slots, can anyone tell me if the bs2 would execute faster if I split the code 50/50 in slot 0 and 1? I'd imagine it takes time for the stamp to move from slot 0 to 1, but if not, would it be better to go ahead and use all 8 program slots and divide the code up equally? Currently I have 70% of the code in slot 0 and 30% in slot 1. It should be noted that the program runs all the way through slot 0 before running all the way through slot 1 and does not jump back and forth to specific parts of the code.

SRLM
09-17-2008, 04:12 PM
You should split the code as the logic dictates, not run speed. The purpose of the slots ( and methods for that matter) is to allow you to easily test and debug your code, and to keep it well maintained. As for time, somewhere it mentions (in the Reference and Syntax manual, maybe?) estimated transition times. If my memory serves me right, it's about 2x longer than the program execution speed (per instruction).

allanlane5
09-17-2008, 08:51 PM
No, the code would run slower if you made more "RUN" calls between the two code slots.

Tracy Allen
09-17-2008, 11:30 PM
I had timed the RUN command on the BS2sx at 300 microseconds. (www.emesys.com/BS2speed.htm#timetables (http://www.emesys.com/BS2speed.htm#timetables))

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

allanlane5
09-18-2008, 01:06 AM
Except, once you've DONE the "RUN" command, you still have to "GOSUB" or "GOTO" the right place in your code to continue.

Besides, isn't 300 uSec like 10 times the normal 30 uSec execution time of a "GOSUB" or something?

I stand by my "it will run slower if you make lots of "RUN" calls"

Tracy Allen
09-18-2008, 02:57 AM
Allen,

I agree that crossing slots will take more time. Marginally slower in the aggregate when there is only an occasional slot switch.

It takes the BS2sx about 100 microseconds to execute a GOTO and longer for a GOSUB. A simple command like HIGH 0 takes about 55 microseconds on the BS2sx. The 300 us for RUN does not account for any additional branching within the new slot. Simply:


LOW 0
HIGH 0
' versus
LOW 0 '<-- in slot 0
RUN 1 ' in slot 0
HIGH 0 ' this in slot 1, 300 microseconds longer due to the RUN

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)