Jump to content
IGNORED

Preview - New integer basic interpreter


Recommended Posts

Hi all!

 

I was busy with work last week, just now have time to answer the thread.

 

vitoco, on 09 Jul 2017 - 4:57 PM, said:

I find very interesting that this version of BASIC has both the parser and the interpreter in the same module, As it has no editor, it just works like a compiler and a runtime... Hey, wait!!!! Why couldn't them be separated modules? A compiler/tokenizer and a linker/runtime. That could give extra RAM memory to the user program. :grin:

 

Seriously, I was impressed to see that the parser was written for the 6502 processor and not for a current platform like DMSC's TBXL-Parser.

Well, that was exactly the challenge, to be able to run in the atari as a standalone environment. Secretly, my goal is to have a platform to write better ten-liners :P

 

The parser is "based" on the TBXL-Parser project, rewritten to simplify the rules. I started modifying that code but realized that was too complicated for simply compiling the program, so I made the parsing rules generate the compiled code directly. Then, I replaced the ML generation with a simple stack-based code, this produced smaller code and allows larger programs.

 

 

pirx, on 05 Jul 2017 - 07:51 AM, said:

is saving parsed programs for quick execution possible?

 

would it be possible to make fb.com accept command line? would be much nicer than menu.

I plan to offer two versions, the "complete IDE version" and the "command line compiler", but I'm currently working in the IDE version as I find that more challenging. Modifying the github sources to accept command line options is nor that difficult, look at the "menu.asm" file.

 

Philsan, on 01 Jul 2017 - 02:46 AM, said:

Thank you very much for your PMG routine, now included in latest FastBasic version.

Which is the easiest way to write, edit and launch FB programs?

 

EDIT

 

I read first post: "What is missing is an editor".

Well, not missing anymore.

 

Attached is my current working version, with integrated full-screen editor, written in FastBasic itself.

 

There are some limitations:

- The editor writes to the screen using the "E:" handler, so it's slow and big :( I tough that using E: would make the editor more "compatible" with screen upgrades, but I don't think it was worth the effort. Probably I will rewrite it using custom write routines.

- Now the IDE is a little less than 9kB, about 3kB bigger than the standalone parser.

- As the edited file is in memory at the same time that the parsed code, you have a lot less memory to your program. A minimal "? fre()" program reports 29kB free.

 

Sadly, the memory limitations makes my "CARRERA3.BAS" program incompatible with the IDE (the program needs 28kB free after load).

 

Attached is the ATR file and the editor sources.

fastbasic-20170710.atr

editor.bas

  • Like 6
Link to comment
Share on other sites

Hi!

 

There is now a new FastBasic version!

 

- Adds a standalone interpreter, and a (cross-)compiler.

- There are optimizations passes in the native compiler (mainly some constant propagation and other simple replacements).

- Adds tokens for numeric constants "0" and "1", makes code smaller.

- More size optimizations in the interpreter, code is smaller and faster.

 

To use the cross compiler, you should download the sources, (either from github at https://github.com/dmsc/fastbasicor attached in this post) and install the CC65 suite from http://cc65.github.io/cc65/getting-started.html

 

Then, you can compile the FastBasic executable with "make bin/fastbasic", and compile your sources with two steps, first compile BAS to ASM and then use CL65 to compile from ASM to XEX:

 

bin/fastbasic MY_PROGRAM.bas MYPROGRAM.asm
cl65 -tatari -Csrc/fastbasic.cfg src/runtime.asm src/interpreter.asm src/io.asm src/alloc.asm src/standalone.asm src/exehdr.asm MY_PROGRAM.asm -o MY_PROGRAM.xex
All the other files are not needed if you only want the command line cross-compiler.

 

Note that the cross-compiler uses the same parsing state machine as the Atari compiler, but has two differences:

- The optimizer, that can produce smaller code,

- You can use "@NAME" as 16bit assembly constants and "@@NAME" as 8bit assembly constants. Those constants are passed to the generated ASM file, so must be available in the final assembly as .global / .globalzp symbols.

 

Well, attached is the ATR (now with the sample programs also compiled, try executing "CARRERA3", "DRAW", etc. The IDE is smaller now, at 8901 bytes, now a minimal "?FRE()" program reports 29424 bytes free, only about 2k less than Atari Basic with DOS.

fastbasic-20170713.atr

fastbasic-src-20170713.zip

  • Like 8
Link to comment
Share on other sites

Secretly, my goal is to have a platform to write better ten-liners :P

 

Well, tenliners requires the shortest way to write many instructions to maximize the 1200 bytes for PUR-120 category. You said that the program editor is free-form, and I haven't seen the sources yet, so I don't know if the parser allows abbreviations and line numbers to comply with the tenliners rules.

 

Could the runtime be splitted in 2 portions like in TurboBASIC XL? Low RAM and under-OS high RAM? That could give about 4 o 6 extra KB of memory to the user program.

  • Like 1
Link to comment
Share on other sites

I don't know if the parser allows abbreviations and line numbers to comply with the tenliners rules.

Yea, abbreviations work nicely and generally you can write the compact style. Interesting plus of this kind of the editor is that the source does not get expanded, so you can work on the compact version.

Link to comment
Share on other sites

Hi!

 

Looks great! You might want to observe the right margin setting at RMARGN ($53) after opening the editor device: this will read $4F if an 80 column display is enabled with the SDX S_VBXE/CON.SYS drivers:

Yes, with minor changes to editor.bas it is now 80 column aware :)

 

I also now use a loop to print blanks (instead of a fixed string), so it's smaller at 8864 bytes.

 

 

Well, tenliners requires the shortest way to write many instructions to maximize the 1200 bytes for PUR-120 category. You said that the program editor is free-form, and I haven't seen the sources yet, so I don't know if the parser allows abbreviations and line numbers to comply with the tenliners rules.

 

Could the runtime be splitted in 2 portions like in TurboBASIC XL? Low RAM and under-OS high RAM? That could give about 4 o 6 extra KB of memory to the user program.

As pirx said, abbreviations are supported similar to turbo-basic, see in "basic.syn" file, lowercase characters in commands are "optional". Also, spaces are generally not required.

 

As a ram-under-rom version, it is possible, but will complicate the code a lot, I think.

 

Attached new version.

fastbasic-20170714.atr

  • Like 7
Link to comment
Share on other sites

Hi!,

 

Well, tenliners requires the shortest way to write many instructions to maximize the 1200 bytes for PUR-120 category. You said that the program editor is free-form, and I haven't seen the sources yet, so I don't know if the parser allows abbreviations and line numbers to comply with the tenliners rules.

 

Could the runtime be splitted in 2 portions like in TurboBASIC XL? Low RAM and under-OS high RAM? That could give about 4 o 6 extra KB of memory to the user program.

As an example, this is the FastBasic version of my tenliner "carrera3d", sadly still does not work in the IDE (not enough memory), but works with the command line version.

 

post-18634-0-87934000-1500071955_thumb.png

 

 

Note that to compile you need the last FastBasic version (from github). That version is now only 8684 bytes, I'm approaching my 8kb target!

CARRERA.BAS

  • Like 2
Link to comment
Share on other sites

Yes, with minor changes to editor.bas it is now 80 column aware :)

 

I also now use a loop to print blanks (instead of a fixed string), so it's smaller at 8864 bytes.

Excellent! This works well using the SVBXE/CON drivers. Scrolling is rather slow, however. I wonder if it would be possible to inject line insert/delete characters at the top of the screen to speed this up somewhat? When scrolling one line back through the document, for example, insert a single line at the top of the window, causing all subsequent lines to move down using whatever efficient block move method is employed by the display driver. You'd then draw the new line at the top of the window in place of the blank one. The VBXE driver uses the blitter for scrolling, so this would be pretty fast (and scrolling would be quicker when using the OS screen handler too). Even if you wanted to scroll by multiples of lines, this technique could offer some improvement. Just a thought, anyway!

  • 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.
Note: Your post will require moderator approval before it will be visible.

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