Jump to content
IGNORED

FastBASIC vs. Assembly


Recommended Posts

MADS 2.1.0 (opt)       SIEVE:    440 ticks in 10 iterations
CC65 2.1.8 (opt)       SIEVE:    602 ticks in 10 iterations
Mad Pascal 1.6.4 (opt) SIEVE:    609 ticks in 10 iterations
Millfork 0.3.14 (opt)  SIEVE:    701 ticks in 10 iterations
Action! 3.6 (opt)      SIEVE:    746 ticks in 10 iterations
FastBasic 4.0 FBI      SIEVE:   6312 ticks in 10 iterations

 

sieve.pas

F0SIEVE.ACT

Edited by zbyti
Action! 3.6 result
Link to comment
Share on other sites

Hi!

1 hour ago, pixelmischief said:

My understanding is that FastBASIC can be compiled and linked.  How does the speed of the resultant executable compare to one generated from assembly code?

The FastBasic code is always interpreted (currently). The compiler writes optimized bytecodes that link to the runtime - the interpreter and the libraries.

 

There is an experimental compiler to 6502 code, but I have not update it much. The limitation of the is that it does not run in the Atari, only in a PC.

 

Have Fun!

 

  • Like 1
Link to comment
Share on other sites

10 minutes ago, dmsc said:

There is an experimental compiler to 6502 code, but I have not update it much. The limitation of the is that it does not run in the Atari, only in a PC.

OK.  So, if I cross-compile my FastBASIC code on the PC, how will the resultant Atari executable perform against assembly code for similar workloads?

 

Let me give some motive here.  I am diving hard into BASIC as a gateway to learning assembler.  I am worried, however, that FastBASIC might be so good that the challenge of learning assembler won't be worth the improvement in performance.  I developed this fear when I saw a YouTube video that showed FastBASIC run a workload in 14 seconds that took compiled TurboXL twice as long and Atari BASIC Rev C ten times as long.

 

Is this something I need to be worried about?

Edited by pixelmischief
Link to comment
Share on other sites

Hi!

36 minutes ago, pixelmischief said:

OK.  So, if I cross-compile my FastBASIC code on the PC, how will the resultant Atari executable perform against assembly code for similar workloads?

 

Let me give some motive here.  I am diving hard into BASIC as a gateway to learning assembler.  I am worried, however, that FastBASIC might be so good that the challenge of learning assembler won't be worth the improvement in performance.  I developed this fear when I saw a YouTube video that showed FastBASIC run a workload in 14 seconds that took compiled TurboXL twice as long and Atari BASIC Rev C ten times as long.

 

Is this something I need to be worried about?

No worries... FastBasic is still an order of magnitude slower than assembler :D.

 

As I said before, I'm writing a new compiler for FastBasic that would produce 6502 assembly code, but that still will be slower than hand-written assembly, so programming in 6502 assembly would always be an useful skill.

 

Have Fun!

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

9 minutes ago, dmsc said:

FastBasic is still an order of magnitude slower than assembler :D.  I'm writing a new compiler for FastBasic that would produce 6502 assembly code, but that still will be slower than hand-written assembly.

Thank you very much for settling that.  And thank you, thank you, THANK YOU for your excellent BASIC variant.  It's so good, I feel like I'm cheating.  By the way, if you fancy an interesting side challenge, a language plugin for Notepad++ would be super cool.

Edited by pixelmischief
  • Like 1
Link to comment
Share on other sites

Hi!

38 minutes ago, pixelmischief said:

Thank you very much for settling that.  And thank you, thank you, THANK YOU for your excellent BASIC variant.  It's so good, I feel like I'm cheating.  By the way, if you fancy an interesting side challenge, a language plugin for Notepad++ would be super cool.

Thanks for your kind words!

 

But regarding Notepad++, I will leave that to others, as I'm a Linux user so don't need that ;) 

 

Have Fun!

 

Link to comment
Share on other sites

Ran into a challenge.

 

Up until now, I have been using Altirra, an OSS BASIC XE cart image, and a host filesystem mount presented as device H1:/H6:.  My workflow cycle has been:

1. Edit the .BAS file in plain text using Notepad++ on the host side (Windows 10 Pro)

2. Load the .BAS file into memory on the emulated Atari with "ENTER"H6:MYFILE.BAS"

3. RUN and debug the code.

4. Return to 1.

 

I can't continue this way with FastBASIC because there is no interactive mode and the loader seems to require a tokenized .BAS file, like something used by the "LOAD/SAVE" commands; instead of the "ENTER/LIST" commands.  Is there a way that I can load a plain text BASIC listing into FastBASIC so that I may continue to use an editor on the host (Notepad++)?

Edited by pixelmischief
Link to comment
Share on other sites

Please ignore.  Altirra presents mounted host paths as both H1: and H6:.  Loading the file from H6: works fine.  I think perhaps the difference between the two is that files loaded from H1: are loaded in binary form and, therefore, do not get the benefit of an ASCII<->ATASCII conversion.  Files loaded from H6:, however, appear to enjoy such a conversion automatically.

Link to comment
Share on other sites

I have notepad++ setup with the FastBasic cross compiler.  I edit in notepad and when I want to run the code I press F7 and it automaticaly opens altira and runs the code.

 

I'll have a look tomorrow to sort out how to set it up if you want, but it's bedtime now :)

Link to comment
Share on other sites

Here's how I setup my PC to use notepad++ to code with FastBasic cross compiler (which requires CC65).

Download the following files:

 

CC65:
https://sourceforge.net/projects/cc65/files/cc65-snapshot-win32.zip/download

 

TURBAN (attachment fur TURBAN under windows 10):
https://atariwiki.org/wiki/Wiki.jsp?page=TURBAN#section-TURBAN-TutorialForWindows10

 

FastBasic cross compiler (fastbasic-v4.3-win32.zip):
https://github.com/dmsc/fastbasic/releases/tag/v4.3

 


Unpack CC65 and put it on your C drive
Unpack FastBasic and put the folder in the CC65 folder
Unpack TURBAN and copy the files from the folder to your FastBasic folder

 

find the fb-int.bat file in your FB folder right click and edit it, place the follow line after line 46 and save it:

 

%xexfile%

 

so it should now look like this:

 

%cc65%cl65 -tatari -C %fbpath%fastbasic.cfg -g %asmfile% %extra% -o %xexfile% -Ln %lblfile% %fbpath%%fb%.lib || exit /b %errorlevel%
%xexfile%
exit /b

 

Now, open one of the example .tur files in the Fastbasic/testproject folder and when you press F6 or F7 a popup will open and after confirmation notepad will open Altirra load up turbbasic and run the file.

 

If you want to run with FastBasic then change turban.bat in the popup to fb-int.bat

 

Notepad will now create a xex file with FastBasic and auto run it using altirra when you press F6/F7, to change it back to use TurboBasic you need to alter the popup to read turban.bat again.


 

Edited by Preppie
  • Like 1
Link to comment
Share on other sites

7 hours ago, Preppie said:

Here's how I setup my PC to use notepad++ to code with FastBasic cross compiler (which requires CC65).

Download the following files:

 

CC65:
https://sourceforge.net/projects/cc65/files/cc65-snapshot-win32.zip/download

 

TURBAN (attachment fur TURBAN under windows 10):
https://atariwiki.org/wiki/Wiki.jsp?page=TURBAN#section-TURBAN-TutorialForWindows10

 

FastBasic cross compiler (fastbasic-v4.3-win32.zip):
https://github.com/dmsc/fastbasic/releases/tag/v4.3

 


Unpack CC65 and put it on your C drive
Unpack FastBasic and put the folder in the CC65 folder
Unpack TURBAN and copy the files from the folder to your FastBasic folder

 

find the fb-int.bat file in your FB folder right click and edit it, place the follow line after line 46 and save it:

 


%xexfile%

 

so it should now look like this:

 


%cc65%cl65 -tatari -C %fbpath%fastbasic.cfg -g %asmfile% %extra% -o %xexfile% -Ln %lblfile% %fbpath%%fb%.lib || exit /b %errorlevel%
%xexfile%
exit /b

 

Now, open one of the example .tur files in the Fastbasic/testproject folder and when you press F6 or F7 a popup will open and after confirmation notepad will open Altirra load up turbbasic and run the file.

 

If you want to run with FastBasic then change turban.bat in the popup to fb-int.bat

 

Notepad will now create a xex file with FastBasic and auto run it using altirra when you press F6/F7, to change it back to use TurboBasic you need to alter the popup to read turban.bat again.


 

If I press F7 on my Notepad++ (installed in C/Programs) nothing happens.

I have to use the old version of N++ inside Turban.w10 folder.

What should I do to let work my N++? 

Link to comment
Share on other sites

2 hours ago, Philsan said:

If I press F7 on my Notepad++ (installed in C/Programs) nothing happens.

I have to use the old version of N++ inside Turban.w10 folder.

What should I do to let work my N++? 

Sorry, I can't help you there - I just use the notepad in Turban.   

Link to comment
Share on other sites

  • 3 weeks later...

Before I start looking for other solutions, I just want to confirm that FastBASIC does not have an exponent operator; something like 2^3 meaning 2 to the third?  I've looked at the docs and tried the prototype I gave as an example.

 

If not, is a bit shift in assembler the best way to go?

 

NEVERMIND: The floating-point interpreter supports it.

Edited by pixelmischief
Link to comment
Share on other sites

If you were just wanting whole number powers (and the powers aren't too large in value) then a small function should suffice, something like:

 

powResult = 0

 

...

 

powX = 2 : powY = 3 : exec Pow

 

...

 

proc Pow

 powResult = 1

 if powY < 1 then exit

 powResult = powX

 while powY > 1

  powResult = powResult * powX

  powY = powY - 1

 wend

endproc

 

Edited by Wrathchild
Link to comment
Share on other sites

Hi!

2 hours ago, pixelmischief said:

Before I start looking for other solutions, I just want to confirm that FastBASIC does not have an exponent operator; something like 2^3 meaning 2 to the third?  I've looked at the docs and tried the prototype I gave as an example.

 

If not, is a bit shift in assembler the best way to go?

 

NEVERMIND: The floating-point interpreter supports it.

Yes, the "power" operator is floating-point only, and always returns a floating point number. If you need the binary equivalent, it is smaller and faster to use a table:

DATA pow2() byte = 1, 2, 4, 8, 16, 32, 64, 128

? 3, pow2(3)
? 0, pow2(0)

 

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