-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the JSC64 wiki!
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:
- To take first steps in javascript (I just started learning javascript a week before starting this toy compiler project)
- To develop a small toy compiler
- Output of a readable assembler listing to learn from. Possibly the most important goal in mind.
- 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).
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.
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).
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.
Added operators "<<" and ">>" for "dbytes".
Added including "macro.asm" and "runtime.asm".
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".
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.