Thursday 11 January 2018

spudge - a new Atari 8 bit programming language

Is there any interest in using a new programming language for Atari 8 bit programming?
Or is this destined to be a language with only one user :)

Last year I returned to write some new code for the Atari (for a bit of nostalgic fun after 30+ years away). It was great relearning how this old machine works and diving back into 6502 coding.

After writing some test programs and thinking about what else I wanted to do I had a ‘to do’ list with dozens of entries - from arcade games to little apps and demos. As much as I enjoy working in assembler I wanted a higher level language for the parts of the program which are not time critical.

After looking at the available options I didn’t find one which felt like a good fit, so I decided to create something new - I’ve always wanted to make a compiler…

I’ve been using a ‘placeholder’ name for the language for a few months until a better one came to mind, but, well, that didn’t happen so it’s still spudge :)

This has been a side project for a few months and I feel it is about 70% done (except for the libraries which may never be finished), hopefully it will be ‘finished’ in another few months (somewhat dependent on other distractions: holidays, gaming, wine, beer… and maintaining my level of interest)

It’s implemented in Perl 5 - creating an asm file which is assembled with MADS (the Mad Assembler) into an xex file, so it should run anywhere a recent version of perl 5 and MADS can be run.

spudge isn’t directly modelled on another language but it is probably most like Action!
It makes similar compromises to Action! - no floating point, ‘static’ subroutine local variables (including parameters), poor support for recursion...
The language is quite different to Action! but supporting much the same functionality with a few extra operators, and a more free form syntax, and, hopefully, often better performance.

What has already been done...

  • variables (local + global): byte, uint, int + pointers to these types, volatile (for memory mapped hardware) and const modifiers, alignment specification, address specification
  • string literals
  • numeric literals: decimal, hex or binary
  • arrays
  • for, while and if statements
  • procedures, functions
  • asm blocks (using standard asm instruction mnemonics)
  • unary operators: -, +, !, not
  • operators: =, +, |, &, ~, xor, or, and, lsh, <<, rsh, >>
  • assignment / update operators: =, +=, -=, &=, |=, <<=, >>=, lsh=, rsh=, &=, |=, ~=, and=, xor=, or=
  • comparison (signed) operators: ==, <>, !=, <=, >=, >, <
  • a few library calls
  • resource level ‘linking’ - only subroutines and variables which are actually referenced are included in the output

What is still to be done...

  • multiplication, division
  • signed comparisons
  • signed / unsigned / pointer expression tracking
  • elsif, else extensions to if
  • subroutines taking a variable number of arguments; esp. printf
  • more: validation, error checking, optimisations
  • user defined types
  • direct access to high / low bytes of 16 bit variables
  • lots of libraries

Is there anyone out there interested in: testing it, trying to use it in its current incomplete state?
Are there any 6502 experts wanting to suggest improvements to the generated code, provide library code (players, sound, graphics, CIO, etc.), code for multiplication, division, signed comparisons...?

Eventually I expect to get around to doing all of these but am happy to start with / integrate other code (but be warned I don’t think it will lead to fame or riches (and for one reason or another I might no be able to accept a particular bit of code))

Oh no!

Is this one of those blogs which limps along for a while and then just fades away...?