wmww/Pinecone

contribute

Closed this issue · 2 comments

hi
i'm working on Pace Runtime (Pacer), which runs Pace Assembly on a virtual machine.
I've created the assembly language and virtual machine and now i'm working on perfomance and bug fixing, And then wanna write a compiler that turns a C-like prgoram to this assembly, but I need help.
I don't know how to get start to write a compiler. can you help me?
this a hello world program in my assembly:

%define assembly_title "Hello"
... ; some definations for assembly manifest
%include "Pacer.inc" ;include Pacer OpCodes

pace_binary_table:
   dep "PSTDLib", "", 0, 1 ; depends on PSTDLib from any author higher than version 0.1
   fun "main", _hmain, _hmain_end - _hmain ;name, offset, size
   var 0x00000000 ;defines a variable with id 0x00000000
pace_binary_table_close

_hmain EQU $
   _read t_string, "Hello, ", 0 ;read a null-terminated string
   _push
   _read t_string, "World!", 0
   _push
   _add ;adds two last objects in stack togother
   _save 0 ;var 0x0000000 = "Hello, " + "World!"
   _load 0  ;read from a variable
   _push
   _calle 0, "println" println(var 0x000000)
   _newobj t_void
   _ret ;return void
_hmain_end EQU $

it assembles with nasm, and output runs on top of my PRT (Pace Runtime).
if i implement this in the C-like language, may lok like this:

#name "hello"
...
#include "PSTDLib"
extern 0, println(1) // println from 0st include with 1 argument(s)
var x; // Pacer has Run-Time Typing for variables
main(0) {
   x = "Hello, " + "World!";
   println(x);
   return void;
}

I'll release a beta version with sources on github soon.
can you target my runtime with your Pinecone?

I forgot, VM has a stack, and a single register called 'self'. each opcode is a single byte, interpreted by runtime and runs in a while (i < size) switch() case: block.

wmww commented

I wrote a blog post on the basics of writing a language, you might find that useful.

I'll look at any PR made to this repo. If you want to target your assembly, it shouldn't be that hard. The C++ transpiler might be a good place to start.

Closing, as this doesn't seem to be any sort of issue with Pinecone.