Jump to content
OLD CS1

What are the impacts of line numbering in BASIC/XB on execution speed?

Recommended Posts

56 minutes ago, Badaboom said:

To code well in basic is to master zen.

 

It isn't the time that matters but the journey. 🙂

Precisely!

BASIC is there for simplicity in use, not for utmost execution speed. Keeping software logical and structured saves time in development and maintenance of the software.

To speed up BASIC it's better to be clever when selecting algorithms, rather than trying to store the lines in a specific order, use alienated variable names (like A, B and C instead of COUNTER, INDEX and SUM), or mess up subroutines with multiple cryptical entries and exits.

 

Refactor your code instead, if you have messed it up. Logic and structure frequently also renders faster execution, as you tend to do less unnecessary things, if your code is in good order.

 

SUB is a very good addition to Extended BASIC. One of its more valuable assets. The local variables are especially valuable if you do, as was suggested above, a library of functions, which you can merge with your program. Regardless of which line numbers the SUB ends up occupying, and regardless of which variable names you have used in the SUB and your main program, it still works the same. That's not at all the same if you use the GOSUB statement, in which case the namespace for your variables are the same as for the main program. You also must keep track of where it is, when you write your code, as it's called by line number reference.

 

Before I made it possible to use Pascal on my TI, I mainly used Extended BASIC. I used the SUB facilities extensively. If it cost some seconds in execution, it paid that back in quicker development.

  • Like 2

Share this post


Link to post
Share on other sites

I dig it.  The test protocol was done against the least important part of the program but the most observable.  The attract mode and marquee make use of the same subroutines as the game loop, so the observation can be correlated with game play.  Specifically, the responsiveness of the input routines.  I have developed an input routine which accepts input from both keyboard and joystick over the years to be as fast as I can get it.  That means not just its exit but also its entry.  Combined with bumming the code, placing the routine strategically in the program becomes important.

 

Thus, while we can observe the disparity in timing between two different instances just running the attract, it may not be observable in game play visually, notwithstanding slow TI BASIC "display-at" routines, but is still perceptible when interacting.

 

Of course, I still put the user input routine way up in the subroutine list (like the fifth subroutine, beyond routines which are used for game setup then lay dormant during game play... ugh.)

Share this post


Link to post
Share on other sites
3 hours ago, apersson850 said:

If there was a need for speed, I usually augmented Extended BASIC with assembly. Or for things that couldn't be done in Extended BASIC.

That is a luxury ;)

  • Like 1

Share this post


Link to post
Share on other sites

With Extended BASIC you got a comprehensive BASIC implementation together with the ability to use assembly support in the 8 K RAM section. That allowed pretty complex applications.

 

I wrote an assembly system to store and retrieve strings in the 8 K RAM. You could also store them in, or read them from, a file.

That was used in a simple wordprocessor, otherwise written in BASIC.

  • Like 1

Share this post


Link to post
Share on other sites

Right, but restricting one's self to just a console, a cassette deck, and XB, or any configuration without an E/A or MiniMemory, one is generally not writing assembly without a special tool or trick.  In any case, such a discussion it outside the scope of this topic, which is to deal with line numbering and subroutines within the confines of BASIC/XB.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...