This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Demo Compiler for Noism (*Update 2*)

Demo Compiler for Noism (*Update 2*)
by on (#134014)
A while back I designed a HLL that would readily compile to CPUs found in old-school consoles, especially 6502 and z80. Some false starts and a lot of work later, I've got a compiler that generates a single file of 6502 code. This is a preliminary release to measure everybody's interest. Right now it shows off the things I really wanted to implement: Nested parentheses, conditional statements with arithmetic and more than one condition using || and && symbols, and register variables for looping and indexing. Function calls are implemented but local vars and passing parameters are pointless until I get the compiler to spit out data segments for the assembler.

Most of the bugs mentioned in the first demo file have been fixed and now you can write a working program, though you'll have to manage the asm project manually.
There's a lot of little bugs that have to be fixed before it can be really useful (mainly with function calls), but I'll start fixing them immediately if I think people will use it.

I was encouraged that over a dozen people downloaded the initial release. If anyone needs a windows .exe made let me know via PM.

Usage: python noism.py demo.noi
The jump labels are compatible with wla-dx
Re: Demo Compiler for Noism (My own programming language)
by on (#134019)
I can't comb through the project right now, but I'm happy to see people experimenting with stuff like this.
Re: Demo Compiler for Noism (*Update 2*)
by on (#134911)
Updated the compiler and demo file: More working syntax with indexing arrays. At this point the 6502 output should be about as robust as I can make it (Outside a few bugs I'm not too worried about). One thing I forgot to mention in the demo file:

while ii2 > 0
When ii2 is assigned to a register, that condition simply becomes
bne -

So if the last instruction before the loop loads any var with 0, that loop will never execute. The workaround for this is to use the dowhile keyword. 'while' inserts a jump over the loop to the conditional check, 'dowhile' doesn't. (I just had a brainstorm to change 'while' into 'whileif' and 'dowhile' into 'while', because it's probably more common for programmers to write loops they expect to always run regardless of the program flow.)

Anyway, I'll eventually get started on making this more useful for building a larger project, but I saw 10 people downloaded the last update, so if anyone thinks they might seriously use this it'd be cool to hear.
Re: Demo Compiler for Noism (*Update 2*)
by on (#134923)
You don't need to change the names of while and dowhile. They already appear consistent with the behavior of while and do/while in C, C++, Java, PHP, and JavaScript, and the behavior of while in Python.