Skip to content

BLikeLang is a primitive compiler for a sub-set of C for the Zilog Z8 in Java.

Notifications You must be signed in to change notification settings

tmssngr/BLikeLang

Repository files navigation

B-like Lang

This is my first approach of writing a primitive compiler from a sub-set of the C-language to Z8 assembly. It can be used together with Z8ASM to compile to binary.

The syntax is close to C (or Java), semicolons are optional. At the moment there is only support for 16 bit signed integer (int) variables - like the built-in Tiny-Basic of the UB8830 processor, an east-german derivative of the Zilog Z8, used in the JU+TE computer. But you also may use var instead.

This project is not meant to be a ready-to-use project, but rather for Java developers. The main class is Compiler. It accepts a source file and writes output.asm in the same directory as the source file. The generated asm file will start with .org %8000, so the program will start be compiled to address 0x8000.

To be able to interact with the operating system, some methods are known by default:

  • void printChar(int character)
  • void printInt(int value)
  • int getMem(int address) - reads the byte from address
  • void setMem(int address, int value) - writes the lower byte of value to address
  • int readInt()

These methods are also configured in the Compiler class as builtInFunctions.

Features ;)

  • var
  • optional ;
  • optional braces for the if expression

Limitations

  • just 16-bit signed integer
  • just a single source file (no includes)
  • no array, no string support

About

BLikeLang is a primitive compiler for a sub-set of C for the Zilog Z8 in Java.

Topics

Resources

Stars

Watchers

Forks

Languages