Jump to content

New community dev tool uploaded: BASLOAD


Recommended Posts

BASLOAD

View File

BASLOAD is best described as a BASIC tokenizer. It takes BASIC source code stored on disk in plain text format, and loads it into RAM. While loading the file, it's tokenzied so that it can be run by the built-in BASIC interpreter.

The purpose of BASLOAD is to enhance the programming experience by letting you edit BASIC source code in the editor of your choosing without using line numbers. Instead of line numbers, named labels are defined as targets for GOTO and GOSUB statements.

Instructions on how to use it and source code is found here:

https://github.com/stefan-b-jakobsson/basload


 

Link to comment
Share on other sites

This is pretty handy! Although, I seem to have run in to a bug where it gets stuck loading forever.  I stepped through the code and it looks like, with my file, the last character is 13, so it keeps reading that and treating it as EOL, but never reaching the EOF part of the code.  I've attached it in case you're curious.  It's basically just the three-line example you gave in the original post.

TEST.BAS

Edited by Ender
Link to comment
Share on other sites

Posted (edited)
1 hour ago, Ender said:

This is pretty handy! Although, I seem to have run in to a bug where it gets stuck loading forever.  I stepped through the code and it looks like, with my file, the last character is 13, so it keeps reading that and treating it as EOL, but never reaching the EOF part of the code.  I've attached it in case you're curious.  It's basically just the three-line example you gave in the original post.

TEST.BAS 37 B · 1 download

Thanks.

I also noticed that bug. I think I have fixed it in version 0.0.2 now available on the download page.

The 0.0.1 version did not call READST to test EOF condition if the last char was LF or CR. It seems that you get only one shot at reading the EOF condition. If you miss that and read one more character, you will never get an EOF.

Source code  available at https://github.com/stefan-b-jakobsson/basload

Unless no more critical bugs are found, I will continue looking at performance issues. Without analyzing it a lot, I guess that the program's function to test for presence of a BASIC token is called a lot.

The label search already uses a checksum to speed up the search.

I think I could calculate the checksum of the tokens as well on program startup, and use these to speed up the token search.

Version 0.0.2 takes about 1 second to load a source file of 70 lines. That corresponds to 1,000 lines per 14.3 seconds. I'm sure it could be made to run a lot faster.

Edited by Stefan
  • Thanks 1
Link to comment
Share on other sites

I've now got a test reimplementation of the token search function that uses a table of token metadata (lengths, checksums and pointers to start of token name).

This seems to have cut the time in half from version 0.0.2 at least for small programs, now using about 0.007 seconds per line of source code, corresponding to 7 seconds to load a source file of 1,000 lines.

Needs a bit of cleanup before publishing. Hopefully I find some time this weekend, but they are promising very nice weather where I live.

Link to comment
Share on other sites

Posted (edited)

Version 0.0.3 now published. It contains:

  • performance improvements,
  • support for ON ... GOTO N1, N2, N3
  • support for labels after THEN without preceding GOTO/GOSUB
  • code cleanup

Please let me know if you use it and find bugs.

Edited by Stefan
Link to comment
Share on other sites

  • 2 weeks later...
Posted (edited)

Published version 0.0.5 just now.

This version adds support for BASIC source code in ISO mode lower case.

On reading the source file, ISO mode lower case text is converted to upper case. The content of strings is, however, left untouched. This should make it possible to program conveniently in ISO mode as well.

Apart from that a few bug fixes. The function that was reading the Kernal version number on startup was still not working properly in all circumstances, which caused some "random" loading failures.

Available in the download section, and on Github.

Edited by Stefan
Link to comment
Share on other sites

7 hours ago, mobluse said:

It says "support for ON ... GOTO N1, N2, N3", but does it also support "ON ... GOSUB N1, N2, N3"?

Yes, it also supports the ON ... GOSUB N1, N2, ... construct.

  • Like 1
Link to comment
Share on other sites

Posted (edited)

Version 0.0.6 published now.

This version makes BASLOAD + X16 Edit = True.

As before, type SYS $9000 to load a BASIC source file. A new feature is that the program remembers the last loaded file, and you may select to reload that file without typing its name.

Another new feature is that you by typing SYS $9003 may load and start the text editor X16 Edit.

BASLOAD expects the X16 Edit executable to be stored in the root folder of the SD Card. The actual CBM DOS path is "//:X16EDIT*.PRG".

If BASLOAD has been used to load a BASIC source file, that file is automatically opened in the editor.

The purpose of these changes is to make the edit-save-load-test cycle more convenient.

A more thorough description of the BASLOAD usage is found on Github: https://github.com/stefan-b-jakobsson/basload

For an illustration of the BASLOAD+X16 Edit workflow, see the attached short video.

Edited by Stefan
  • Like 1
Link to comment
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.

 Share

×
×
  • Create New...

Important Information

Please review our Terms of Use