BASIC compilers

Basic and Machine Language

Moderator: Moderators

User avatar
LoadError
Vic 20 Hobbyist
Posts: 120
Joined: Sat Feb 17, 2007 2:44 pm
Website: http://digilander.libero.it/pyrotech/
Location: Italy
Occupation: FG Soft

BASIC compilers

Post 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?
Commodore VIC-20 n. WG-C-275517 - manufactured in Western Germany in 1983
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Re: BASIC compilers

Post by Boray »

I think so.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: BASIC compilers

Post 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?
User avatar
Kweepa
Vic 20 Scientist
Posts: 1314
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Re: BASIC compilers

Post 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.
User avatar
LoadError
Vic 20 Hobbyist
Posts: 120
Joined: Sat Feb 17, 2007 2:44 pm
Website: http://digilander.libero.it/pyrotech/
Location: Italy
Occupation: FG Soft

Re: BASIC compilers

Post 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?
Commodore VIC-20 n. WG-C-275517 - manufactured in Western Germany in 1983
User avatar
beamrider
Vic 20 Scientist
Posts: 1446
Joined: Sun Oct 17, 2010 2:28 pm
Location: UK

Re: BASIC compilers

Post 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.
Last edited by beamrider on Fri Jan 05, 2018 4:50 am, edited 1 time in total.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: BASIC compilers

Post by Mike »

@beamrider: PM sent. :)
armypavarmy
Vic 20 Hobbyist
Posts: 107
Joined: Wed Oct 02, 2013 1:54 am
Location: Italy

Vic Compiler Program

Post 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 368 times
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Vic Compiler Program

Post 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
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: BASIC compilers

Post 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?
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: BASIC compilers

Post 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
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: BASIC compilers

Post 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.
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: BASIC compilers

Post 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
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: BASIC compilers

Post 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
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: BASIC compilers

Post by srowe »

I've mailed David to let him know about the broken links.
Post Reply