Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source

Update: The project has moved to Sourceforge.

Attention Slashdot crowd, here is a little background:

This application is a recompiled version of the original Commodore 64 binary – it is not a reimplementation, so while it runs at pretty much the maximum possible speed, it is still 100% compatible. The huge C file in the archive has been produced by feeding the original 6502 code into my static recompiler and optimizing it with LLVM. The original operating system interface (character I/O, LOAD, SAVE etc.) has been reimplemented in native C, so Commodore BASIC interfaces nicely with OS X/Windows/Unix – you can use pipe I/O, and you can pass the filename of a BASIC program on the command line.

Yes, you could also just run a standard C64 emulator, but it wouldn’t be nearly this speed, and everything would run inside a sandbox; and there would be no way to interface this to your OS.

A while back, I released Apple I BASIC and Commodore BASIC as a scripting language for Mac OS X 10.5 on Intel. It did not work on any other OS or on a different CPU type.

Today, we are releasing Commodore BASIC as a Scripting Language – it works on Linux, Windows, Mac OS X 10.4/10.5 (Intel and PowerPC), and you even get the source, so you can adapt it to other operating systems and CPUs.

Download it here: cbmbasic.zip

The archive comes with binaries for Mac OS X and Windows. The source compiles on Linux, Windows and Mac OS X. All code is BSD-licensed. Main work by Michael Steil, speed optimizations, Linux and Windows fixes by James Abbatiello.

The core of the BASIC interpreter is in the file cbmbasic.c, which is platform, endianness and bitness independent. For all I/O, it calls out into runtime.c, do it should be able to adapt this project for any OS by just changing runtime.c.

All function calls that the core interpreter can’t handle end up in kernal_dispatch() in runtime.c, where a switch statement dispatches these to C functions. For Commodore BASIC, runtime.c has to support several Commodore KERNAL library routines. Some of them are very important (CHRIN, CHROUT) and some are only used for certain BASIC statements (LOAD, SAVE, OPEN, SETTIM). runtime.c does not implement all functions yet.

Feel free to port cbmbasic to your system and architecture of choice, and extend runtime.c to support more functions. If you like, send your changes back to us (mist64<at>mac<dot>com, abbeyj<at>gmail<dot>com), so we can update the main project and give your changes to everyone. We’re also interested how fast you can get it with different compilers and settings.

See my old article for more info as well as some insights on how it is done.

See also:

pixelstats trackingpixel

100 Responses to “Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source”

  1. [...] Trovate tutto su Pagetable.com. [...]

  2. Scott Houdek says:

    Wow, what a great idea!, but do i have to do a lot of “poke” and “peek” to get high resolution graphics and sound?:)

  3. Scott Houdek says:

    It also lack of a user manual for this type interpreter!!!!!!!!!!!!!!!

  4. [...] are lots of scripting languages for Unix/Linux and Windows, but this one just kinda blew me away, and brought back some [...]

  5. [...] you’re new here, you may want to subscribe to my RSS feed. Thanks for visiting!This is quite cool: “Today, we are releasing Commodore BASIC as a Scripting Language – it works on [...]

  6. [...] old interpreters are still with us. We have niche QBasic hobby sites still kicking, we have an open-source Commodore BASIC emulator that just got released for Windows and Linux, and Microsoft itself has returned to its roots with [...]

  7. [...] meraklÄą bir programcÄą, bu programlama dilini gĂźnĂźmĂźz bilgisayarlarÄąnda kullanÄąlabilir hale getirmiş. Bu “yaşlÄą” dil ne işimize yarar demeyin. Nostalji yapmak [...]

  8. OisĂ­n says:

    Where did you get the idea to use CBM basic for scripting on a modern OS? The first computer I ever had was a C64, when I was about 8 years old in 1990. I started learning to program, but never really got the knack for it until I discovered GFA Basic for my next computer, an Atari ST, a couple of years later.
    I quickly came to feel that C64 basic sucked horribly, was inexpressive, hard-to-use and unfriendly – at least compared to GFA (not having line numbers was another nice thing :)).

  9. [...] Pagetable ha publicado un programa que trae de vuelta el mitico lenguaje BASIC de ordenadores de Commodore como es el Commodore 64, a nuestro sistema actual. El programa es multiplataforma, de cĂłdigo abierto y estĂĄ diponible para Linux, MacOS X y Windows. Y lo mas importante, te permite usarlo como un lenguaje de scripting en tu sistema. [...]

  10. KindlyRat says:

    I must report that GW-BASIC is still being used, runs on any Windows platform and is available free at:
    http://www.geocities.com/KindlyRat

  11. [...] as a Scripting Language 17 11 2008 On October 28th Michael Steil announced on his blog Pagetable the release of Commodore BASIC as a scripting language for Linux, Windows and Mac (OS X 10.4/10.5 [...]

  12. [...] pagetable.com Âť Blog Archive Âť Commodore BASIC as a Scripting Language for UNIX and Windows – now …. [...]

  13. [...] Wow does this bring back memories. Find info about it here. [...]

  14. [...] Sunset Boulevard. Free binary downloads are available for Windows and Mac, source code for Linux. Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source [...]

  15. [...] Página del proyecto, Código fuente del [...]

  16. marco says:

    Zuruck in die Zukunft mit c64! Eureka!!

  17. [...] emuladores retro Jueves, 18 de Diciembre de 2008 Ir a comentarios Dejar un comentario Commodore BASIC para Mac OS X, Linux y Windows, una versiĂłn para ordenadores modernos de ese lenguaje que tantas [...]

  18. [...] Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source, Michael Steil over at pagetable has statically recompiled and modified Commodore’s original BASIC so that it can be used as a scripting language in UNIX and Windows. [...]

  19. LarryG says:

    I’m able to run cbmbasic scripts but can anyone tell me how to run code in direct mode?
    All I get is syntax errors.

  20. Allan Higgins says:

    Turn CAPS LOCK on to aviod syntax errors.
    C64 manuals can be found here:

    http://www.lemon64.com/manual/

    http://www.devili.iki.fi/Computers/Commodore/C64/Programmers_Reference/page_iii.html

    -Allan

  21. Curt Woodard says:

    You are aware that the Commodore 64 used the Motorola 6510 processor, correct? It was the Vic-20 that used the 6502. Can you be sure that this is 100% compatible with the Commodore 64′s version of basic?

  22. Curt Woodard says:

    OK, I am thinking assembler…my bad :)

  23. MagerValp says:

    Either way the 6510 is 100% compatible with the 6502, as it uses the same CPU die. The only difference is the added 6-bit I/O register and tristate logic.

  24. [...] I like blogs, however the blogs I like are those I can find on Google through a search engine in answer to a specific problem, or are linked too from a specific community and are therefore interesting because of that.I’d like this to be one of those blogs.Hi! My name is Stuart Monteith. I created this blog because of my involvement in the Apache Kato incubator project.This project aims to develop JSR-326, a Java standard for an API that allows tools to debug Java programs, possibly JVMs.Why should you care?Ultimately, the aim is to solve programs with Java programs in a different way that you might be used to.  Anyone using more static languages, such as C and C++, will be used to attaching debuggers (such as windbg, dbx, gdb) to running programs. Fine, but they could also attach to programs that had crashed, or generated a core file for some other reason. You can’t do that in Java.That is a lie. You can’t do that on every JVM from every vendor and write tools to do it. I’ll explain more tomorrow…And finally, a link to a most excellent, non-Java blog: http://www.pagetable.com/?p=48 [...]

  25. Рис. 6.7. Приспособления…

    183
    182
    Рис. 6.7. Приспособления для определения ве…

  26. The 6510 processor was NOT by Motorola! You’re thinking of the 65000 which was used in Macintoshes and the Amiga.

    The 6510 was from MOS semiconductor, who Commodore bought and owned. Ironically, the Apple II and the Atari 2600 used the 6502 processor and had to buy them from Commodore.

  27. Peter Lund says:

    You mean the 68000. And probably also the 6800 series, also from Motorola.

  28. Ric says:

    Versions of GWBASIC for Windows and Linux would be great too. I havnt got a clue how to do that myself. I love the simplicity of the old languages – makes them quicker to learn and use for the occassional programmer. A dBase language would be another contender for this treatment, since I’ve been searching for something I can use to create simple databases without success. Thanks very much for making this available.

  29. MiaM says:

    Ric:

    Isn’t it possible to run GWBASIC.EXE directly under Windows? (at least on 32-bit windows)

  30. Al Boyanich says:

    This is so hot. My SGI Irix machine now is able to run legacy CBM BASIC much faster than in VICE. Now, how do I peek and poke the CRiMe graphics on my O2 ?

  31. I think the Versions of GW BASIC for Windows and Linux would be great to,
    The old languages are makes them quicker to learn, Anyone using more static languages, such as C and C++, will be used to attaching debuggers to running programs.

  32. [...] – CBM Flavor” is free of charge, runs on iPhone/iPod touch and iPad, and is based on pagetable.com’s Open Source cbmbasic project, a recompiled version of the original Commodore 64 binary, so the [...]

  33. everything about java…

    [...]Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source « pagetable.com[...]…

  34. Best kerala resorts kumarakam…

    [...]Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source « pagetable.com[...]…

  35. AIMP Standalone…

    [...]Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source « pagetable.com[...]…

  36. Vanessa says:

    This sounds wonderful! What would be even better: C128 BASIC 7.0 with Walrusoft’s “BASIC 8″ extension.

    Is this doable?

  37. SunKing2 says:

    When I saw this I was giddy. Hey, and it works like a charm! Thanx!

  38. rob345 says:

    good job!! tnks

  39. I do not even know how I ended up here, however I assumed this put up used to
    be great. I don’t realize who you are however certainly you are going to a famous blogger if you happen to are not already. Cheers!

  40. Hi there all, here every one is sharing these knowledge, so it’s nice to read this web site, and I used to pay a quick visit this webpage all the time.

  41. It’s an amazing piece of writing in support of all the web users; they will get benefit from it I am sure.

  42. Hi!

    Hmm, cbmbasic.c looks as if it was generated.

    I’m writing a C64 emulator (http://svn.nomike.com/playground/trunk/emu/C64/ ), so do you still have the original source and generator of cbmbasic.c somewhere? If so, could I read it? I could use that in order to help me learn to use LLVM properly and/or debug the emu :-)

    Since you have experience with LLVM, do you know how to use LLVM JIT for dynamic languages?

    The LLVM builder seems to be strangely datatype insistent.

  43. bitly.com says:

    It’s awesome to go to see this website and reading the views of all colleagues regarding this article, while I am also eager of getting know-how.

  44. Jefferey says:

    I will immediately clutch your rss as I can not to
    find your email subscription hyperlink or e-newsletter
    service. Do you’ve any? Please let me understand so that I could subscribe. Thanks.

  45. Splusk.de says:

    Splusk.de…

    [...]Commodore BASIC as a Scripting Language for UNIX and Windows – now Open Source « pagetable.com[...]…

  46. Fantastic blog you have here but I was wondering if you knew of any forums
    that cover the same topics talked about in this article?
    I’d really like to be a part of group where I can get feedback from other knowledgeable individuals that share the same interest. If you have any recommendations, please let me know. Many thanks!

  47. Wow, awesome weblog format! How lengthy have you ever been running
    a blog for? you make running a blog look easy. The full look of your web site is fantastic, let
    alone the content material!

  48. hen, ein Privatdarlehen, ein Auto Darlehen aufgabeln
    oder Hypothek. 9-Keep an eye on the budget-especially until the campaign takes
    off and becomes profitable. Sie brauchen nicht den besten Kredit zu zahlen Fortschritte zu bekommen.

  49. free ipad says:

    free ipad

    Hello very cool site!! Guy .. Beautiful .. Wonderful .
    . I’ll bookmark your web site and take the feeds also? I am happy to find so many helpful info right here within the post, we’d like
    work out extra strategies on this regard, thank you for sharing.
    . . . . .

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word