dmsc Posted December 31, 2017 Share Posted December 31, 2017 (edited) Note: a new version is available over this post. Hi all As a new-year present, I released a new version of FastBasic. It's only a minor bugfix release from last one: - Fixes a bug with floating-point comparisons - Adds more usage information to the cross-compiler. - Fixes display corruption in the editor. - Allows comments after any statement. As always, the full source is over github, and you can download the release at https://github.com/dmsc/fastbasic/releases/full manual at https://github.com/dmsc/fastbasic/blob/master/manual.md and sample programs are included in the ATR or in the source at https://github.com/dmsc/fastbasic/tree/master/samples/int and https://github.com/dmsc/fastbasic/tree/master/samples/fp Over github I included the cross-compiler for Linux, Windows and macOS, but I only tested the Linux and Windows ones. For usage instructions of the cross-compiler, see at https://github.com/dmsc/fastbasic/blob/master/compiler/USAGE.md fastbasic-r2.atr Edited February 19, 2018 by dmsc 20 Quote Link to comment Share on other sites More sharing options...
bfollett Posted December 31, 2017 Share Posted December 31, 2017 I was just looking at the manual on your website. Just a quick note, I noticed #4 in the section "About the Syntax" had a small typo. It says to use semicolons to between statements, but shows a colon: "Multiple statements can be put on the same line by placing a semicolon : between statements." The programing language looks interesting, do you have a feel on how it compares speed wise to turbo basic/ turbo basic compiled? Thanks, Bob Quote Link to comment Share on other sites More sharing options...
dmsc Posted December 31, 2017 Author Share Posted December 31, 2017 (edited) Hi! I was just looking at the manual on your website. Just a quick note, I noticed #4 in the section "About the Syntax" had a small typo. It says to use semicolons to between statements, but shows a colon: "Multiple statements can be put on the same line by placing a semicolon : between statements." The programing language looks interesting, do you have a feel on how it compares speed wise to turbo basic/ turbo basic compiled? Thanks, Bob Thanks for the correction, updated over github. With respect to speed, it depends on the program, but with the included SIEVE benchmark, the runtime in jiffies (1/60 of second, in NTSC, screen ON): - Standard TurboBasic XL: 7941 (100%) ( 28%) - basicParser optimizaed TurboBasic XL: 7537 (105%) ( 29%) - Compiled TurboBasic XL: 2210 (360%) (100%) - FastBasic IDE: 1330 (597%) (166%) - FastBasic cross-compiled: 1314 (604%) (168%) So, FastBasic is 6 times faster than standard TurboBasic XL and 1.7 times faster than compiled TurboBasic XL. This is not a fair comparison, as FastBasic uses integers for the main operations, but TurboBasic XL uses floating point. On the other hand, FastBasic is still an interpreter and a lot slower than compiled 6502 assembly. For example, MadPascal times the above benchmark at 98 jiffies, so it's 13 times faster than FastBasic. Attached are the benchmark sources. sieve-turbobas.bas.txt sieve.pas.txt sieve-fastbasic.bas.txt Edited December 31, 2017 by dmsc 1 Quote Link to comment Share on other sites More sharing options...
bfollett Posted December 31, 2017 Share Posted December 31, 2017 (edited) Wow, that's a pretty decent speed improvement. I'm going to have to give it a try. Bob Edited December 31, 2017 by bfollett 1 Quote Link to comment Share on other sites More sharing options...
Xuel Posted December 31, 2017 Share Posted December 31, 2017 What optimizations does the cross-compiler do that the IDE doesn't? Quote Link to comment Share on other sites More sharing options...
dmsc Posted January 1, 2018 Author Share Posted January 1, 2018 Hi! What optimizations does the cross-compiler do that the IDE doesn't? The cross-compiler performs a simple peephole pass with some rules: - Propagates constants operations (so, for example A=2+1 becomes A=3, A=1*B becomes A=B, etc.) - Converts *2 and *4 (and A+A) to shift left - Removes comparisons with 0 (so, "IF A=0" becomes "IF NOT A") - Converts A=A+1 and A=A-1 to "INC A" and "DEC A" - Converts ? #0, INPUT #0, GET #0, PUT #0 to the operations with the #0 implied. - Converts the number 0 and 1 to tokens "TOK_0" and "TOK_1" - Converts numbers from 2 to 255 to BYTES. Also, it emits all PROCs at the end of the program instead of actual location in the source, this generates smaller code. I plan to add more optimization pases in the future, converting the opcodes to a tree representation first and then lowering from there, as it's currently done in my TurboBasic XL parser. 5 Quote Link to comment Share on other sites More sharing options...
Xuel Posted January 1, 2018 Share Posted January 1, 2018 Very cool. Does the IDE do any optimizations? Quote Link to comment Share on other sites More sharing options...
+Philsan Posted January 1, 2018 Share Posted January 1, 2018 Instead of a single XEX, perhaps someone would need an ATR image to be created, with XEX file and other needed files (graphics, tunes...). Based on FB's batch file by dmsc and Turban's batch file by Irgendwer, I made this batch file: @echo off set basfile=%1 set asmfile=%~d1%~p1%~n1.asm set xexfile=autorun.sys C:\cc65\fb\fastbasic-fp %basfile% %asmfile% || exit /b %errorlevel% C:\cc65\bin\cl65 -t atari -C C:\cc65\fb\fastbasic.cfg %asmfile% -o %xexfile% C:\cc65\fb\fastbasic-fp.lib || exit /b %errorlevel% set imagename=%~d1%~p1%~n1.atr set diskdir=%~dp1\atr copy %xexfile% %diskdir% dir2atr -b Dos25 720 %imagename% "%diskdir%" if %errorlevel% neq 0 exit /b %errorlevel% Altirra.exe /pal /bootrw %imagename% You need to put files in "fb/atr" folder. The program will be compiled and an ATR will be created with all files. The program will be started in Altirra (Altirra must be in PATH). 1 Quote Link to comment Share on other sites More sharing options...
+Philsan Posted January 1, 2018 Share Posted January 1, 2018 Perhaps with FastBasic people without much experience would start programming. Therefore I mode a simple guide for newbies. Feel free to give me suggestions. WINDOWS INSTALLATION Download CC65 from here: http://cc65.github.io/cc65/getting-started.html#Windows Unzip all folders in C Make folder C:\cc65\fb Download fastbasic-windows from here: https://github.com/dmsc/fastbasic/releases/ Unzip it in C:\cc65\fb Download and install text editor Notepad++ from here: https://notepad-plus-plus.org/ In the menu select Language/V/VisualBasic WINDOWS USE Start Command Prompt Type cd c:/cc65/fb Write code on Notepad++ and save PROGRAMNAME.bas in C:\cc65\fb In Command Prompt type fb PROGRAMNAME.bas After a few second PROGRAMNAME.xex will be created in C:\cc65\fb If you want the program started in emulator add "Altirra.exe %xexfile%" line in fb.bat and fb-int.bat. 3 Quote Link to comment Share on other sites More sharing options...
dmsc Posted January 1, 2018 Author Share Posted January 1, 2018 Hi! Very cool. Does the IDE do any optimizations? Not currently, the IDE directly transforms the code the tokens, following the set of rules in the syntax file. I have tried to keep the IDE as smaller (and faster) as possible, and currently the speed gains for the optimization pass are not that great. I tried adding a constant-propagation pass using the syntax rules, but the parser became really slow, so I removed it. 1 Quote Link to comment Share on other sites More sharing options...
XL Freak Posted March 12, 2018 Share Posted March 12, 2018 another optimization you could consider for the compiled code is expression pre-arrangement, so the included interpreter doesn't have to rearrange the expression on each pass, or at all. the compiler could arrange the expression, ie. A=4*((A+B)/Z), into A,B,+,Z,/,4,*A,= which the interpreter could execute quicker since it doesn't have to test the come-off and go-on stack values. it'd already be done. this is an idea i have for an android project i may do at some point in the future. hope this helps... 2 Quote Link to comment Share on other sites More sharing options...
dmsc Posted March 12, 2018 Author Share Posted March 12, 2018 Hi! another optimization you could consider for the compiled code is expression pre-arrangement, so the included interpreter doesn't have to rearrange the expression on each pass, or at all. the compiler could arrange the expression, ie. A=4*((A+B)/Z), into A,B,+,Z,/,4,*A,= which the interpreter could execute quicker since it doesn't have to test the come-off and go-on stack values. it'd already be done. this is an idea i have for an android project i may do at some point in the future. hope this helps... This is what the current compiler does, it transform the source to a stack-based byte-code. This is done in the IDE, at the same time the code is parsed. In your example, the code is converted to: VAR_ADDR 'A' BYTE 4 VAR_LOAD 'A' VAR_LOAD 'B' ADD VAR_LOAD 'Z' DIV MUL DPOKE What the optimizer does is apply transformations to the above byte-code after the parsing is complete, replacing sequences with shorter/faster ones. One of the novel ideas from the FastBasic IDE is that there is only one pass from source text to the byte-code, not separated tokenization plus parsing plus code-generation. This is done using a PEG like parser, that matches each source character with a list of rules described in a syntax file, and emits bytecode from the same syntax. The parser has some limitations, and as it does not support memoization it is slow for complex expressions, but it works well for a simple language like BASIC, and produces a complete parser in less than 3.5kB. 4 Quote Link to comment Share on other sites More sharing options...
XL Freak Posted March 12, 2018 Share Posted March 12, 2018 sounds great! can't wait to get my system up and running so i can try it Quote Link to comment Share on other sites More sharing options...
+Larry Posted March 18, 2018 Share Posted March 18, 2018 Is anyone successfully using FastBasic with an Atari Dos (2.0, MyDos, etc.)? Or is it "hooked" to BEWE Dos? BEWE Dos looks a lot like Sparta at a casual glance. Thanks, Larry Quote Link to comment Share on other sites More sharing options...
dmsc Posted March 18, 2018 Author Share Posted March 18, 2018 Hi! Is anyone successfully using FastBasic with an Atari Dos (2.0, MyDos, etc.)? Or is it "hooked" to BEWE Dos? BEWE Dos looks a lot like Sparta at a casual glance. Thanks, Larry Should work with any DOS, only requirement is that MEMLO be less than $2000. As the IDE is self contained, you only need the "FB.COM" or "FBI.COM" programs in the disk, rest of files on disk are the manual and samples. Quote Link to comment Share on other sites More sharing options...
+Larry Posted March 20, 2018 Share Posted March 20, 2018 Hi dmsc- I've found several Dos versions with MEMLO of less than $2000. Thanks. But if I try to do a binary load of FB.COM or FBI.COM with another Dos version, then they launch OK, but immediately gives an ERROR 170. What file is missing if the program is not launched by BEWE Dos? Perhaps the HELP.TXT file is typically needed but will not load if using another Dos? Not saying it crashes or anything, but it's interesting to start with an error message. Or perhaps there is a built-in hook to the STARTUP.BAT file? -Larry 1 Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted March 20, 2018 Share Posted March 20, 2018 Loads under DOS 2.5 and finds HELP.TXT OK, so there don't appear to be any dependencies on a particular DOS. I do think the file not found error could be suppressed regarding HELP.TXT, though, since once you get the hang of things it's not needed and it would be preferable to simply start with an empty editor (and no error message). Quote Link to comment Share on other sites More sharing options...
dmsc Posted March 21, 2018 Author Share Posted March 21, 2018 Hi! Hi dmsc- I've found several Dos versions with MEMLO of less than $2000. Thanks. But if I try to do a binary load of FB.COM or FBI.COM with another Dos version, then they launch OK, but immediately gives an ERROR 170. What file is missing if the program is not launched by BEWE Dos? Perhaps the HELP.TXT file is typically needed but will not load if using another Dos? Not saying it crashes or anything, but it's interesting to start with an error message. Or perhaps there is a built-in hook to the STARTUP.BAT file? -Larry Yes, the editor loads 'D:HELP.TXT' at start to show a simple help screen, if not found an error is shown but the IDE continues working ok. If you don't like the error, simply copy the file, or write a new one with whatever you want to show at start. Loads under DOS 2.5 and finds HELP.TXT OK, so there don't appear to be any dependencies on a particular DOS. I do think the file not found error could be suppressed regarding HELP.TXT, though, since once you get the hang of things it's not needed and it would be preferable to simply start with an empty editor (and no error message). Suppressing the error would make the IDE bigger (because the editor simply calls "LoadFile" with the filename set to 'D:HELP.TXT'), to make the error disappear it is easier to simply write an empty HELP.TXT file. I'm now finalizing a new version, there are one major bug in the STR$ function in the 3.3 version that is fixed in current github sources, I will release the 3.4 version before Friday, so it's available for the ten-liners competition 2 Quote Link to comment Share on other sites More sharing options...
+Larry Posted March 21, 2018 Share Posted March 21, 2018 I see what happens... In my case, I've been loading FB.COM from D4:. D1: is a hard drive, and FB isn't there, yet. But FB is expecting the HELP.TXT file to be there on D1: (not on D4:), hence the ERROR 170. Mystery solved! And FB seems quite happy with MyDos 4.5x! -Larry Quote Link to comment Share on other sites More sharing options...
flashjazzcat Posted March 21, 2018 Share Posted March 21, 2018 Suppressing the error would make the IDE bigger (because the editor simply calls "LoadFile" with the filename set to 'D:HELP.TXT'), to make the error disappear it is easier to simply write an empty HELP.TXT file. Good point. Assuming there was no free ZP address for a flag, suppressing errors could take eleven bytes (3 bytes to set flag to known value of 0 of $FF, 3 to INC or DEC flag once initialisation phase is done, 3 to test bit 7 of flag in load procedure, and 2 bytes to branch accordingly). Worse yet, it's possible to receive errors that relate to a help file which was located but couldn't be loaded owing to IO errors, etc, so you end up filtering conditions in order to do things properly. Your suggested method is fine. Quote Link to comment Share on other sites More sharing options...
gozar Posted March 30, 2018 Share Posted March 30, 2018 Suppressing the error would make the IDE bigger (because the editor simply calls "LoadFile" with the filename set to 'D:HELP.TXT'), to make the error disappear it is easier to simply write an empty HELP.TXT file. Does the help.txt need to be loaded? Eliminating the loading process would free up space. Quote Link to comment Share on other sites More sharing options...
dmsc Posted March 30, 2018 Author Share Posted March 30, 2018 Hi! Does the help.txt need to be loaded? Eliminating the loading process would free up space. Yes, loading the help.txt is not needed and removing it currently frees 24 bytes, but I like the program to be "discoverable", as the key combinations are not universal. Quote Link to comment Share on other sites More sharing options...
funkheld Posted September 9, 2018 Share Posted September 9, 2018 (edited) Can the code start from $ 2000 to $ 3000. I want to make a graphics screen from $ 2000 to $ 3000 with dli. Thank you. Greeting Edited September 9, 2018 by funkheld Quote Link to comment Share on other sites More sharing options...
funkheld Posted September 9, 2018 Share Posted September 9, 2018 (edited) how can you divide these values of the data line into several lines? It is an asm program. data ml() byte = $68,$68, $A2, $00, $A9, $00, $9D, $40, $BC, $9D, $40, $BD, $9D, $40, $BE, $9D, $40, $BF, $E8, $D0, $F1, $A9, $2D, $A2, $0C, $60 ? i, usr(adr(ml),i) repeat until Key() asm-source clearscreen : ldx #0 lda #0 loop sta $bc40,x sta $bd40,x sta $be40,x sta $bf40,x inx bne loop lda #45 ldx #12 rts Edited September 9, 2018 by funkheld Quote Link to comment Share on other sites More sharing options...
dmsc Posted September 9, 2018 Author Share Posted September 9, 2018 Hi funkheld!, Can the code start from $ 2000 to $ 3000. I want to make a graphics screen from $ 2000 to $ 3000 with dli. If you are using the cross-compiler, it is easy, just pass "--start-addr 0x3000" to the CL65 command line: cl65 -tatari -C fastbasic.cfg -g --start-addr 0x3000 miprog.asm -o myprog.xex -Ln myprog.lbl fastbasic-fp.lib Sadly, the current compiler script does not support passing options to the CL65 command line directly, you have to manually invoke the commands. The other, not recommended option, is to modify the file "fastbasic.cfg", the default STARTADDR values is at line 23. If you are using the native compiler. This it not as easy, as the native compiler don't do a linker phase, the only option is to reassemble the whole IDE with a lower start address. It is basically the same as the above, but you have to recompile and modify the Makefile with the added option. Here you can also modify the file "fastbasic.cfg" and recompile, this will change the default value for the IDE and the cross-compiler. how can you divide these values of the data line into several lines? It is an asm program. data ml() byte = $68,$68, $A2, $00, $A9, $00, $9D, $40, $BC, $9D, $40, $BD, $9D, $40, $BE, $9D, $40, $BF, $E8, $D0, $F1, $A9, $2D, $A2, $0C, $60 ? i, usr(adr(ml),i) repeat until Key() You need to repeat the "data byte" line: data ml() byte = $68,$68, $A2, $00, $A9, $00, $9D, $40, $BC, $9D, $40, $BD, data byte = $9D, $40, $BE, $9D, $40, $BF, $E8, $D0, $F1, $A9, data byte = $2D, $A2, $0C, $60 This is a quirk of the parser that allows it to parse one line at a time without context, this makes the native parser use a lot less memory. ? i, usr(adr(ml),i) repeat until Key() asm-source clearscreen : ldx #0 lda #0 loop sta $bc40,x sta $bd40,x sta $be40,x sta $bf40,x inx bne loop lda #45 ldx #12 rts That don't work: you are calling the USR function with one parameter "i", but you are not removing the parameter from the stack. Simply call it without the second parameter: "? usr(adr(ml))". Hope it helps! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.