Skip to content
puregorill edited this page Feb 9, 2023 · 45 revisions

Welcome to the JSC64 wiki!

JSC64 (read: Javascript Compiler for the (Commodore) 64)

A nonprofessional hobbyist attempting to write a compiler in Javascript for the NMOS 6502/6510 processor and the Commodore 64.

I am not a professional coder in any way and to be honest I don't really know what I am doing.

Everything here is for personal use and educational purposes only. Everything is absolutely without warranty.

If something does not work or causes damage, I take no responsibility in any way (see LICENSE).


This project fulfills certain goals for me personally:

  1. To take first steps in javascript (I just started learning javascript a week before starting this toy compiler project)
  2. To develop a small toy compiler
  3. Output of a readable assembler listing to learn from. Possibly the most important goal in mind.
  4. No .exe files and unreadable source, just a browser (and some runtime files that are also readable) and you are ready to go. Possibly the most important goal in mind (combined with 3).

I'm more of a C person, Basic person and Pascal person, so I don't have much knowledge about all the neat OOP features of Javascript and I think I'm going to program Javascript more C style and less the way JS should probably be programmed. So I am using all that stuff like procedures/functions, global variables and more nasty things.

But I have to stand by that, OOP style was never mine and I could never figure out what it was all about. Maybe it's my age, I'm from the C64 era and learned to code like that (as a hobbyist, mind you).

How can you execute JSC64?

Just start <main...html> (there are 2 versions to choose from) in a browser, and the rest of it should be pretty self-explanatory.

You can compile the testfile or type something yourself (or copy and paste) in the left text field.

If you want to run the generated assembly code (it is kind of ACME style), then I recommend to copy and paste it into C64Studio. From there you can build the binary code and run it directly with e.g. the C64 emulator VICE. Both can be found with a few mouse clicks via google.

Better follow the quick start tutorial.


C64Studio is a Commodore development system for Windows on the PC.

VICE ("Versatile Commodore Emulator", for Windows also WinVICE) is a program that can execute programs for Commodore's 8-bit computers, e.g. the C64, the PET, VIC20 and much more.

ACME is a free crossassembler. It supports NMOS 6502 and more processors. The ACME project and its documentation can be found on github. There is also a German-language page that explains the ACME syntax very well. The corresponding google translation to english works quite well.

One word of warning

English is not my native language, I use translation software along with my own not so bad English skills. Nevertheless, I'm afraid some wording may be strange (from time to time).

Project progress

2023-01-25

The mathematical parser already works correctly for "dbyte" and the operators "+" and "-".
It does some minor optimizations on the code. The pattern "sta _T0_: lda _T0_" is deleted. _T0_ is a temporary variable for expression calculation. The result remains in the accumulator anyway and therefore does not have to be saved first and then reloaded.

2023-01-29

Added operators "<<" and ">>" for "dbytes".
Added including "macro.asm" and "runtime.asm".

2023-02-05

The mathematical parser now works for "dbyte" and "byte" and the operators "<< >> + - / *", all on an 8-bit basis.
Macros and runtime procedures exist for this, which are included in the programm if they are needed. The list of runtime macros/procedures now includes "runtime.asm", "macro.asm", "def64.asm", "messages.asm".

2023-02-09

Refactoring of the "let" code to multiple source files.
Math parser now works for "word" with operator "+".
Math parser for "byte" and "dbyte" is getting close to being complete. Operators "+ - * / & | ^ << >>" are implemented on "byte" and "dbyte" level.
Optimization of "emitLDA" and "emitSTA" so that the same operand is not loaded twice unnecessarily.
"print" with immediate string 'print "hello world"' added.