ABC compiles Basic V to 6502? [ABC65]

bbc/electron apps, languages, utils, educational progs, demos + more
Post Reply
User avatar
BigEd
Posts: 3562
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

ABC compiles Basic V to 6502? [ABC65]

Post by BigEd » Tue Jul 07, 2020 10:38 pm

Paul Fellows, about the 1:18 mark of his recent ABUG talk, says he had a version of the Archimedes Basic Compiler which could compile BASIC V to 6502 code. He says it could produce code for the main 32k user space on the BBC Micro, or for sideways RAM space, possibly spanning multiple banks.

Is that version available at all? Do we know anything about the code quality?
Screen Shot 2020-07-07 at 22.36.42.png
Last edited by BigEd on Thu Jul 09, 2020 8:03 am, edited 1 time in total.

User avatar
davidb
Posts: 2906
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: ABC compiles Basic V to 6502?

Post by davidb » Wed Jul 08, 2020 12:32 am

Wasn't there a Dabs Press product called Cross-32? I think that was a cross-assembler for the 6502 that ran on the Archimedes.

User avatar
daveejhitchins
Posts: 6004
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: ABC compiles Basic V to 6502?

Post by daveejhitchins » Wed Jul 08, 2020 7:04 am

davidb wrote:
Wed Jul 08, 2020 12:32 am
Wasn't there a Dabs Press product called Cross-32? I think that was a cross-assembler for the 6502 that ran on the Archimedes.
Cross-32 was, and still is (available now :D ), a Baildon Electronics product. It was sold through ICS BITD.

Am I remembering correctly (?) Didn't Paul say that assembler was available in the 'Pack' (introductory Pack/learning pack - or something? Learning Curve)? I have one of those in my loft (at least the pack I'm thinking of!) I'll check after breakfast.

Dave H :D

Edit: Remembered the 'pack' name 8)

User avatar
tricky
Posts: 4794
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: ABC compiles Basic V to 6502?

Post by tricky » Wed Jul 08, 2020 9:04 am

I was wondering if the cross-compiler would work in modern BBC BASIC as a way of streamlining cross-compilation.

User avatar
daveejhitchins
Posts: 6004
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: ABC compiles Basic V to 6502?

Post by daveejhitchins » Wed Jul 08, 2020 10:09 am

Ah! Found it . . . In Paul's video it starts at 1:18. I had remembered it incorrectly :oops: (no surprises there!) but nearly right. He mentions that he used it to compile Genesis that was in the Learning Curve pack.

Dave H :D

Edit: It looks as if it's in the DDE bundle. That's probably not the version that's being sought? But needs checking!

User avatar
davidb
Posts: 2906
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: ABC compiles Basic V to 6502?

Post by davidb » Thu Jul 09, 2020 12:20 am

paulb reminded me that the product was called ABC65. There are probably adverts for it in the Acorn magazines of the late 80s/early 90s.

User avatar
BigEd
Posts: 3562
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by BigEd » Thu Jul 09, 2020 8:05 am

Oh, great! It was, then, a separate product. I found this pre-announcement in the Dabhand guide to the Archimedes Operating System:
Dabs Press will be adding to their increasing range of quality books and software for a wide range of micros during the next year. For the Archimedes this includes ABC65 a 6502 cross compiler allowing 6502-based code and Sideways RAM images to be generated from BASIC V developed and tested on the Archimedes. The stand-alone 6502 code can then be transferred to a BBC B, B+, Master 128 or Master Compact computer. ABC65 will be available in the second quarter of 1989.
Edit, and in the News section of July 1989 issue of Archive magazine:
News: Dabs Press
ABC65 Archimedes to 6502 cross compiler
Last edited by BigEd on Thu Jul 09, 2020 8:13 am, edited 2 times in total.

RobC
Posts: 3013
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by RobC » Thu Jul 09, 2020 8:11 am

And here's the advert from the July 89 Acorn User:
abc65.jpg

User avatar
BigEd
Posts: 3562
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by BigEd » Thu Jul 09, 2020 8:14 am

There's an indication here that it was indeed released, as a product with a price. Although it's a press release not an advert, and might possibly be a misinterpretation of a "coming soon".

In New Computer Express (8 July 89, only 58p!):
Press Dabs pilercom[???]
An interesting example of reverse engineering from Dabs Press, with the release of ABC65, a compiler which takes Archimedes BASIC V programs and makes them work on the BBC Micro as 6502 machine code. The Archimedes is plainly a better program development environment so it sort of makes sense. The main and obvious problem of finding enough space in a BBC Micro to hold the code is overcome by using sideways RAM storage where available. One hundred page user guide and serial transfer software included. Asking price is £69.95.

User avatar
Lardo Boffin
Posts: 2216
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by Lardo Boffin » Tue Jul 14, 2020 6:32 pm

I just watched that video (excellent video thanks Paul) and was wondering about the compiler. Is it available anywhere? Has anyone used it in anger to see how it works or the size of the code produced?
Presumably it could be run on an emulator?
Adventure Language on GitHub
Atom, issue 5
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA

User avatar
BigEd
Posts: 3562
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by BigEd » Sun Aug 09, 2020 4:53 pm

It feels to me like ABC65 is Missing In Action - has anyone got a copy, or ever seen a copy?

Edit: elminster did find the manual:

PMF
Posts: 10
Joined: Sun Sep 06, 2020 2:13 pm
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by PMF » Wed Sep 30, 2020 4:42 pm

Hello there

Lots of questions about my Basic Compiler(s) ... let me try to answer them

ABC - the Arm Basic Compiler - was writen by myself. It is writen IN BBC Basic - so it is a large Basic program which reads other basic programs and spits out functionally equivalent machine code. To generate the code it uses Basic's built in in-line assembler ... so when if finds you have writen A% = 37 it generates [OPTopt% : MOV R0,#37 : STR R0,[R12,#offsetforA%] : ] and by sticthcing all these into a file you get the resulting object code.

It supports ALMOST all of the BASIC V language. There are some parts that are near-impossible and non-sensical to attempt such as the EVAL function, which would require you keep the entire source code and a copy of the interpreter to hand.. but most programs don't make use of that anyway I think.

There are other restrictions - such as not writing improperly nested loops... The compiler can't know in advance the path your code is going to take, so it needs to take a STATIC view of which ENDWHILE goes with which WHILE .. with the interpreter that is done on the fly at runtime - when it searches for things downward through the text. The result is the same, for most "sane" programs. However you can write torture-test programs that will make the interpreter do some rather surprising things, and for which the compiler with chastise you.

One of the things that IS supported in the compiler which may surprise you is the use of the in-line assembler... and it is 100% compatible.

This of course is a good thing, bu was essential for my cunning plans... which were that the compiler compile itself. And indeed it does so. You can run the Source code of the compuler under the interpreter, and feed a copy of the source code in as input. Out comes an object code programme which (if there are no bugs) should be functionally the equivalent of the source.

It does, and this works. You can run the object code so-created and use it to compile programs.. including of course itself... and get a second-generation copy... I do this every time and compare the 2nd object with the first - they should be identical unless there is a bug.

The Compuler Source code is around 230 K bytes of basic, excluding some Include files, and the source of the library code. So around 500K all told.

Interestingly the first stage (running the source code on the interpreter) took around 28Hours to do and get a complete working object code compiler on my original machine. Running the object code compiler to compile its own source took 55mins. This is a factor of around 30 x speed up.

Of course the compiler is not using much floating point, and not doing much I/O - its mostly integer and string processing internally. But I was quite pleased and that sort of speed up was typical for many of the programmes that were written with it.

Good examples were !Genesis and the Acorn Level 4 fileserver program. the benefit of compilation was very substantial.

Now, to the question of the 6502

Yes, I did make a version which compiled not to ARM code by to 6502 code directly !Abc65. Sadly despite a major search for the source code of that version I can't find it. It would be interested to see it again. I have not given up hope of a bunch of floppy discs turning up somewhere with the backups on, but no luck yet.

It compiled the same feature set, BASIC V - but output 6502 machine language. That code could be targetted to run (a) in normal ram (b) as a sideways ROM loaded into sideways RAM or "Bas128" style spanning across 4 x 16k banks of sideways rom. (The compiler created four slabs of code, and dealt with arranging all the page-rom bank flipping to hop from one to another seamlessly). I wish I could find it for you.

There was also a code generator for the 68000 for it. But I've lost that too.

I am at the moment doing some updates to the !ABC compiler for RISCOS for the first time in 25 years, and have caught-it-up to the latest spec of BBC BASIC.

Oh, and there may be some new features for both !ABC and BBC BASIC just around the corner, but I'm sworn to secrecy on those at the moment.

TTFN
Paul Fellows
Head of Languages, Acornsoft, 1983-85
Microsystems Software Manager, Acorn 85-88

User avatar
BigEd
Posts: 3562
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by BigEd » Wed Sep 30, 2020 4:49 pm

PMF wrote:
Wed Sep 30, 2020 4:42 pm
Now, to the question of the 6502

Yes, I did make a version which compiled not to ARM code by to 6502 code directly !Abc65. Sadly despite a major search for the source code of that version I can't find it. It would be interested to see it again. I have not given up hope of a bunch of floppy discs turning up somewhere with the backups on, but no luck yet.
Thanks for the update Paul, and for the search, even though it's presently a negative result. I haven't given up hope either!

PMF
Posts: 10
Joined: Sun Sep 06, 2020 2:13 pm
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by PMF » Wed Sep 30, 2020 7:02 pm

If I get too bored maybe I'll write a new one. It would be better the second time around - but:- I used the floating point libarary that Acornsoft developed for its never-released Fortran compiler for the Beeb to handle single and double precision floats - and I don' fancy doing all of that again!

The other big chunk of work was a heap-manager for all the runtime strings and arrays - I think I remember how that worked, and could do it again.
Paul Fellows
Head of Languages, Acornsoft, 1983-85
Microsystems Software Manager, Acorn 85-88

User avatar
BeebMaster
Posts: 3734
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by BeebMaster » Thu Oct 01, 2020 9:22 pm

So the Level 4 file server was written in BASIC and then compiled into ARM code? Is the source available at all, I wonder, either BASIC or assembler?
Image

Bobbi
Posts: 527
Joined: Thu Sep 24, 2020 12:32 am
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by Bobbi » Thu Oct 01, 2020 9:27 pm

OMG who would write a file server in BASIC!?

User avatar
BeebMaster
Posts: 3734
Joined: Sun Aug 02, 2009 5:59 pm
Location: Lost in the BeebVault!
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by BeebMaster » Thu Oct 01, 2020 9:29 pm

Well, Acorn, like the Atom and System and BBC Micro Level 1 file servers of course.

And if it was going to be put through Paul's magical BASIC compiler, then why not for Level 4 as well?
Image

Soruk
Posts: 802
Joined: Mon Jul 09, 2018 11:31 am
Location: Basingstoke, Hampshire
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by Soruk » Fri Oct 02, 2020 5:06 pm

PMF wrote:
Wed Sep 30, 2020 4:42 pm
Oh, and there may be some new features for both !ABC and BBC BASIC just around the corner, but I'm sworn to secrecy on those at the moment.
Now I'm intrigued....
Matrix Brandy BASIC VI (work in progress)

RobC
Posts: 3013
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by RobC » Fri Oct 02, 2020 5:40 pm

Bobbi wrote:
Thu Oct 01, 2020 9:27 pm
OMG who would write a file server in BASIC!?
The Beeb's BASIC is very fast and there's the in-line assembler for time critical bits :D

Bobbi
Posts: 527
Joined: Thu Sep 24, 2020 12:32 am
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by Bobbi » Fri Oct 02, 2020 8:28 pm

Yeah I know. I take a similar approach in my 8 bit development using cc65 (C cross compiler for 6502) with inline asm for the critical bits. However C is a lot nicer than BASIC for writing anything halfway complicated (like a file server.)

RobC
Posts: 3013
Joined: Sat Sep 01, 2007 10:41 pm
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by RobC » Fri Oct 02, 2020 8:31 pm

Bobbi wrote:
Fri Oct 02, 2020 8:28 pm
Yeah I know. I take a similar approach in my 8 bit development using cc65 (C cross compiler for 6502) with inline asm for the critical bits. However C is a lot nicer than BASIC for writing anything halfway complicated (like a file server.)
True - C is my preferred language but I guess it wasn't really an option on the 6502 until much later in the Beeb's life.

Bobbi
Posts: 527
Joined: Thu Sep 24, 2020 12:32 am
Contact:

Re: ABC compiles Basic V to 6502? [ABC65]

Post by Bobbi » Fri Oct 02, 2020 8:32 pm

Probably not. Compiling C natively on 6502 is pretty awful too.

I do have Aztec C v3.2 for the Apple II (from the late 1980s) which works okay but compile times are rather excessive!

Post Reply

Return to “8-bit acorn software: other”