Jump to content
  • 0
Sign in to follow this  
x16tial

Fun? with BASIC

Question

So, I'm messing around with building BASIC code with Assembly and here is some possibly fun info for you:
I wanted to see how many lines of basic I could cram into the available BASIC RAM.
So, this program:
0 A$="*"
1 PRINTA$;
...
With line 1 repeated as many times as possible, incrementing by 1, resulted in a program with ending line number 4292.
So, when RUN, prints 4292 asterisks, not even filling up one 80x60 screen (4800 characters).
The program ends on byte $9ef1, consuming 38641 bytes (I'm not counting basic's 00 at $0800)

Run time of the ml program to build the BASIC program is imperceptible, basically instantaneous, I could put in some timing code to get a number, but meh 🙂

Later!

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

OK, so you're using an assembly program to build out a BASIC program.  No transpiler, this is all on-board.

Looks like you're (correctly) using the ? token for PRINT.  Otherwise I think it would be appx half as many lines.

Interesting, amusing, and interesting.

 

Edited by rje

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

Yeah, all basic keywords (and operators) are tokenized whether you input the full keyword, or use the shortcut. PRINT's token is $99, for example.  So all *V2* keywords and operators use only one byte.  They also are all $80 and greater (bit 7 set).  The new keywords introduced in the X16 ROM take two bytes, one for the "escape" code $CE, and another for a token, again $80 and greater.  There are 68 V2 keywords, and 8 operators, making 76 tokens ($80 through $CB), and X16 includes 22 new keywords ($80 through $95).

Edited by x16tial

Share this post


Link to post
Share on other sites
  • 0

And a bit of other info.  My program above is pretty inefficient on space, by doing one statement per line.  Every BASIC line has 5 bytes of "overhead", so each additional statement on one BASIC line saves 5 bytes per statement, by not having it on its own line.  I might play with how many PRINTA$;'s I could get by packing in the statements, and I could do it two ways.  One way, by using the 80 character  limit per line that you get when entering lines in the screen editor and a 2nd way that allows you to get 250 bytes per line, when building the BASIC lines from Assembly.  Possibly more "Fun" to come!  😄

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

I actually ran out of space with a space-trader game I was working on over the summer... there was less than 4K of heap left... but about 10K of the program was read in from data statements, so it's not a pure example...

 

Edited by rje

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
Answer this question...

×   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.

Sign in to follow this  

×
×
  • Create New...

Important Information

Please review our Terms of Use