Page 1 of 2

BASIC compilers

Posted: Thu Jan 04, 2018 1:29 pm
by LoadError
Looking for a way to compile a BASIC game to gain speed, I found just a single solution which is to use Austrocompiler on the VIC itself, which will generate pseudocode.
I haven't found any other solution. I've found a few cross compilers for 6502, but none seems to work with CBM BASIC.
Is Austrocompiler really the only solution?

Re: BASIC compilers

Posted: Thu Jan 04, 2018 2:38 pm
by Boray
I think so.

Re: BASIC compilers

Posted: Thu Jan 04, 2018 3:12 pm
by Mike
As you are the OP of a similar thread, "Redefine the charset with 8K+ RAM", it would be really interesting to know what followed up upon that.

Indeed, Austro-Comp is the only known BASIC compiler for the VIC-20, and as you've noted, it doesn't even compile to machine code, but only intermediary P-code. This is executed somewhat faster than by the BASIC interpreter, but it is nowhere as fast as machine code.

The obstacles in using AC had been clearly laid out in said thread, a rather moderate speed increase but added hassles when it comes to adding a custom character set, etc. ... ... you find my opinion to that over there as well. ;)

So, when it comes to your current project, what are your objections to instrument it with machine code sub-routines?

Re: BASIC compilers

Posted: Thu Jan 04, 2018 6:56 pm
by Kweepa
You can use Sink-20 to profile your BASIC to see which lines are expensive, if it's not immediately obvious.
It's a work in progress but for simple profiling it should fit the bill.

Re: BASIC compilers

Posted: Fri Jan 05, 2018 3:57 am
by LoadError
@Mike: thanks for pointing me at the old thread. I'd somehow forgotten about its existence :oops: I have no objections to writing some routines in machine code, other than I am totally green on the subject. My plan is to start with reading the old VIC 20 Programmers' Guide and move the first steps, then maybe at some point get to a 2.0 release with machine code routines.

@Kweepa: thanks, I didn't know about Sink-20, will give it a spin. Here?

Re: BASIC compilers

Posted: Fri Jan 05, 2018 4:42 am
by beamrider
Another (much better IMO) option to consider is switching to C. C is also a much more useful language in the wider context and games written in it are closer to ML performance as the releases from the Misfit stable aptly demonstrate.

I created a wrapper for Robert Hurts's Sprite Libary at the end of this thread.

If there was any interest I could develop this bootstrap project a bit more adding a soundplayer etc giving newcomers to the Vic 20 an easy route to develop high quality games without the ardour of learning ML and writing a sprite engine.

Re: BASIC compilers

Posted: Fri Jan 05, 2018 4:47 am
by Mike
@beamrider: PM sent. :)

Vic Compiler Program

Posted: Tue Feb 20, 2018 6:55 am
by armypavarmy
Hello
I have a "Vic Compiler" program
does anyone know how to use it?
Attached for tests
Thank you
greetings Armando
vic compiler.zip
(4.32 KiB) Downloaded 371 times

Re: Vic Compiler Program

Posted: Wed Feb 21, 2018 1:42 am
by Mike
I took a quick peek. It's most probably the same breed of Tiny BASIC compiler that has been discussed in the thread 'Should these tapes be archived?', and to quote from there:
vicist wrote:Apparently, this only compiles mathematical programs, like the sample provided within the program. It won't compile full basic programs.

A description of the compiler can be found here
Not so useful beyond toy programs.

...

BTW, it's exactly the same "VIC compiler.prg" that's been archived on zimmers.net for ages ...

ftp://ftp.zimmers.net/pub/cbm/vic20/uti ... mpiler.prg

Re: BASIC compilers

Posted: Fri Aug 31, 2018 2:02 am
by nippur72
I would like to write a BASIC compiler with modern tools (e.g. compiling on the PC and generating a .prg file to be consumed), I think it would be a great fun to write. It could generate both p-code and pure machine language.

The only problem (aside the lack of time) is that I don't know very well the ROM BASIC interpreter, in order to simulate the needed calls (e.g. calling math functions). Can you suggest me a starting point? Is there an article, webpage or something?

Re: BASIC compilers

Posted: Fri Aug 31, 2018 4:30 am
by srowe
There's a commented disassembly of the BASIC (and KERNAL) ROM here

https://eden.mose.org.uk/gitweb/?p=rom- ... kernal.asm

There is an extensive description of the BASIC routines in "Compute's Tool Kit: BASIC", PDF available on Bombjack

http://69.60.118.202/books/commodore/bo ... _Basic.zip

Re: BASIC compilers

Posted: Fri Aug 31, 2018 5:40 am
by nippur72
regarding the vic 20 kernal rom disassembly... I wasn't aware there was one! :o :shock: I always referenced C64's one!! that's absolutely great, thanks!

As for the PDF link, it gives me a 404 error.

Re: BASIC compilers

Posted: Fri Aug 31, 2018 6:22 am
by srowe
nippur72 wrote: As for the PDF link, it gives me a 404 error.
Odd, I pasted it from the browser, try finding it manually in http://www.bombjack.org/commodore/books.htm

Re: BASIC compilers

Posted: Fri Aug 31, 2018 6:38 am
by nippur72
it looks like they have been removed (or protected) as it still gives me 404.

But I was able to get it from archive.org:

https://ia601705.us.archive.org/2/items ... ations.pdf

Re: BASIC compilers

Posted: Fri Aug 31, 2018 6:50 am
by srowe
I've mailed David to let him know about the broken links.