Skip to content

Compiler Tutorial

Joe Pfeiffer edited this page Dec 1, 2018 · 8 revisions

Disclaimer:

What you are about to read/follow will not have any useful value or improve your life in any way. It may eat your laptop. End Disclaimer.

But hey, you're not here for useful stuff. Let's do a thing.

Getting started:

First, we need to build and install the tool chain. For this, you will need the following:

  • Linux or MacOS, because Unix is best.
  • A relatively recent version of nodejs and npm. Anything more recent than 8.0 should be fine.
  • The dotnet core sdk. Get it here: https://dotnet.microsoft.com/download
  • Some make program. On ubuntu, install build-essentials. On mac, you can probably get it by installing xcode and friends.

Got the things? Good. Let's install the toolchain.

  • First clone the repo: git clone git@github.com:jpfeiffer16/Synacor.git
  • cd into the root of the repo and run npm install -g . That will install the assembler, disassembler, and vm.
  • cd into the compiler dir with cd cs/syncomp/src
  • Install the compiler with sudo make install
  • Now you should have the syncomp, syn-vm, syn-asm, and syn-disasm commands installed.

If you have issues with any of these steps, just open an issue and I'll check it out.

Now that is done we can make a simple program and run it.

  • run mkdir helloworld somewhere
  • cd helloworld

Now create a file called something like hello.bc. Let's start with this:

#include "stdlib.bc"

println("Hello, world");

Now compile and run it with: cat hello.bc | syncomp - | syn-asm - > hello.bin then run syn-vm -b hello.bin

You should get Hello, world greeting you on your terminal.

Clone this wiki locally