Java_Grinder for 6502/65816/AVR8

Introduction

Ony of my favorite projects to work on is java_grinder, an ahead-of-time bytecode compiler for microcontrollers and older computers.

My efforts include support for the 6502, 65816, and AVR8 microprocessors. Demos and games have been created for the Commodore 64, Apple IIgs, and Atari 2600. There is also support for the W65C265SXB microcontroller board from Western Design Center.

Implementation

The M6502 and AVR8 code generators both use a 16-bit software stack for variables and addresses, which operates independently of the hardware stack. This avoids having to work around the return addresses of subroutines.

I used a different approach for W65816: Variables are stored on the main processor stack, and an extra stack is used for return addresses. This increases the overhead of subroutines but lowers it otherwise, as it permits the use of the "stack relative" addressing mode. Most operations are inlined anyway thanks to the higher code density of the chip.

All use signed 16-bit integer math (except division, which is unsigned) with a numerical range of -32768 to +32767. (32-bit and floating point types are currently unsupported.)

The switch statement is currently unsupported in java_grinder.

API

Each processor/platform may have it's own API for things like graphics, sound, I/O ports, etc. Some classes (like Memory, or Joystick are universal in nature while others (like VIC for C64) are more specific.

Class Definitions

Code Generators

Project Code Samples

The C64 API documentation (work-in-progress) is available here:

Java API for C64

Videos

Gallery

Files

Note: These have been tested on the VICE (C64) and Stella (Atari 2600) emulators, but not real hardware.

Snake for C64

Space Revenge for Atari 2600