Jump to content
  • Advertisement
  • entries
    744
  • comments
    1927
  • views
    586598

Hey

Aardvajk

1061 views

Wow. Been a while. Must be years since I last updated this. So I'm still alive and I'm working on a toy version of LLVM purely for my own amusement.

Pv is a virtual machine executable that executes a fairly small virtual instruction set:

enum class Reg : std::uint8_t
{
    Pc,
    Bp,
    Sp,
    Dx,
    Invalid
};

const char *toString(Reg v);

enum class Op : std::uint8_t
{
    End,

    SetRI,

    SubRI,
    AddRI,

    CopyRR,
    CopyRA,
    CopyAR,
    CopyAI,
    CopyAA,

    PushR,
    PopR,

    Call,
    Ret,
    JmpZ,

    Add,
    Sub,
    Mul,
    Div,
    Mod,

    Not,
    Neg,

    Lt,
    LtEq,

    Conv,

    Alloc,
    Free,

    Service,

    Invalid
};

Nothing very fancy.

Pi (Paul's Intermediate language) is a typeless language in the sense that variables only have sizes. It is designed to be translated line by line by Pi.exe into bytecode for Pv.

Pc is the higher level language. I appreciate I am not explaining this well but there are quite a few features now. Today I added the facility to overload operator<< to allow myself to create a std.ostream functionality. Assume stdlib.ph provides std.print functions for std.ints and for ptr std.char (pointer to char):
 

include("stdios.ph");

class Age
{
    func new(v:std.int) ... v(v) { }

    var v:std.int;
}

func operator<<(o:ref std.ostream, a:ref Age):ref std.ostream
{
    return o << a.v;
}

class Person
{
    func new(n:ptr std.char, a:Age) ... n(n), a(a) { }

    func name():ptr std.char { return n; }
    func age():Age { return a; }

    var n:ptr std.char;
    var a:Age;
}

func operator<<(o:ref std.ostream, a:ref Person):ref std.ostream
{
    return o << a.name() << " is " << a.age() << " years old";
}


func main()
{
    std.out() << Person("Paul", Age(44)) << ".\n";
}

Where stdios.ph looks like this:

namespace std
{

class ostream
{
}

func operator<<(:ref ostream, :std.int):ref ostream;
func operator<<(:ref ostream, :std.bool):ref ostream;
func operator<<(:ref ostream, :ptr std.char):ref ostream;

func out():ref ostream;

}

And is implemented like this:

include("stdios.ph");
include("stdlib.ph");

func std.operator<<(o:ref std.ostream, v:std.int):ref std.ostream
{
    std.print(v);
    return o;
}

func std.operator<<(o:ref std.ostream, v:std.bool):ref std.ostream
{
    std.print(v);
    return o;
}

func std.operator<<(o:ref std.ostream, v:ptr std.char):ref std.ostream
{
    std.print(v);
    return o;
}

var instance:std.ostream;

func std.out():ref std.ostream
{
    return instance;
}

So Pc.exe transforms each translation unit into a .pi file. For script.pc above, the produced .pi looks like this:

var "#global.script.pc1":11 = string(" years old"), char(0);
var "#global.script.pc3":3 = string(".\n"), char(0);
var "#global.script.pc2":5 = string("Paul"), char(0);
var "#global.script.pc0":5 = string(" is "), char(0);
func[autogen] "std.ostream.new(ref ptr std.ostream):std.null <method>":0
{
    arg "std.ostream.new.this":8;
    var "@rf":1;
    clrf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_std.ostream.new.#scope0";
    jmp "#end_function";
"#no_return_exit_std.ostream.new.#scope0":
"#end_function":
}
func[autogen] "std.ostream.new(ref ptr std.ostream,ref ptr std.ostream):std.null <method>":0
{
    arg "std.ostream.new.this":8;
    arg "std.ostream.new.#tempcopy":8;
    var "@rf":1;
    clrf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_std.ostream.new.#scope1";
    jmp "#end_function";
"#no_return_exit_std.ostream.new.#scope1":
"#end_function":
}
func[autogen] "std.ostream.delete(ref ptr std.ostream):std.null <method>":0
{
    arg "std.ostream.delete.this":8;
    var "@rf":1;
    clrf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_std.ostream.delete.#scope2";
    jmp "#end_function";
"#no_return_exit_std.ostream.delete.#scope2":
"#end_function":
}
func[autogen] "std.ostream.operator=(ref ptr std.ostream,ref ptr std.ostream):ref ptr std.ostream <method>":8
{
    arg "std.ostream.operator=.this":8;
    arg "std.ostream.operator=.#tempcopy":8;
    var "@rf":1;
    clrf "@rf";
    push "std.ostream.operator=.this";
    push &"@ret";
    store 8;
    pop 8;
    setf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_std.ostream.operator=.#scope3";
    jmp "#end_function";
"#no_return_exit_std.ostream.operator=.#scope3":
"#end_function":
}
func "Age.new(ref ptr Age,std.int):std.null <method>":0
{
    arg "Age.new.this":8;
    arg "Age.new.v":4;
    var "@rf":1;
    clrf "@rf";
    push "Age.new.v";
    push "Age.new.this";
    push size(0);
    add size;
    store 4;
    pop 4;
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Age.new.#scope4";
    jmp "#end_function";
"#no_return_exit_Age.new.#scope4":
"#end_function":
}
func[autogen] "Age.new(ref ptr Age,ref ptr Age):std.null <method>":0
{
    arg "Age.new.this":8;
    arg "Age.new.#tempcopy":8;
    var "@rf":1;
    clrf "@rf";
    push "Age.new.#tempcopy";
    push size(0);
    add size;
    load 4;
    push "Age.new.this";
    push size(0);
    add size;
    store 4;
    pop 4;
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Age.new.#scope5";
    jmp "#end_function";
"#no_return_exit_Age.new.#scope5":
"#end_function":
}
func[autogen] "Age.delete(ref ptr Age):std.null <method>":0
{
    arg "Age.delete.this":8;
    var "@rf":1;
    clrf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Age.delete.#scope6";
    jmp "#end_function";
"#no_return_exit_Age.delete.#scope6":
"#end_function":
}
func[autogen] "Age.operator=(ref ptr Age,ref ptr Age):ref ptr Age <method>":8
{
    arg "Age.operator=.this":8;
    arg "Age.operator=.#tempcopy":8;
    var "@rf":1;
    clrf "@rf";
    push "Age.operator=.#tempcopy";
    push size(0);
    add size;
    load 4;
    push "Age.operator=.this";
    push size(0);
    add size;
    store 4;
    pop 4;
    push "Age.operator=.this";
    push &"@ret";
    store 8;
    pop 8;
    setf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Age.operator=.#scope7";
    jmp "#end_function";
"#no_return_exit_Age.operator=.#scope7":
"#end_function":
}
func "operator<<(ref ptr std.ostream,ref ptr Age):ref ptr std.ostream":8
{
    arg "operator<<.o":8;
    arg "operator<<.a":8;
    var "@rf":1;
    clrf "@rf";
    allocs 8;
    push "operator<<.o";
    push "operator<<.a";
    push size(0);
    add size;
    load 4;
    push &"std.operator<<(ref ptr std.ostream,std.int):ref ptr std.ostream";
    call;
    push &"@ret";
    store 8;
    pop 8;
    setf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_operator<<.#scope0";
    jmp "#end_function";
"#no_return_exit_operator<<.#scope0":
"#end_function":
}
func "Person.new(ref ptr Person,ptr std.char,Age):std.null <method>":0
{
    arg "Person.new.this":8;
    arg "Person.new.n":8;
    arg "Person.new.a":4;
    var "@rf":1;
    clrf "@rf";
    push "Person.new.n";
    push "Person.new.this";
    push size(0);
    add size;
    store 8;
    pop 8;
    push "Person.new.this";
    push size(8);
    add size;
    push &"Person.new.a";
    push &"Age.new(ref ptr Age,ref ptr Age):std.null <method>";
    call;
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Person.new.#scope1";
    jmp "#end_function";
"#no_return_exit_Person.new.#scope1":
"#end_function":
    push &"Person.new.a";
    push &"Age.delete(ref ptr Age):std.null <method>";
    call;
}
func "Person.name(ref ptr Person):ptr std.char <method>":8
{
    arg "Person.name.this":8;
    var "@rf":1;
    clrf "@rf";
    push "Person.name.this";
    push size(0);
    add size;
    load 8;
    push &"@ret";
    store 8;
    pop 8;
    setf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Person.name.#scope2";
    jmp "#end_function";
"#no_return_exit_Person.name.#scope2":
"#end_function":
}
func "Person.age(ref ptr Person):Age <method>":4
{
    arg "Person.age.this":8;
    var "@rf":1;
    clrf "@rf";
    push &"@ret";
    load 8;
    push "Person.age.this";
    push size(8);
    add size;
    push &"Age.new(ref ptr Age,ref ptr Age):std.null <method>";
    call;
    setf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Person.age.#scope3";
    jmp "#end_function";
"#no_return_exit_Person.age.#scope3":
"#end_function":
}
func[autogen] "Person.new(ref ptr Person,ref ptr Person):std.null <method>":0
{
    arg "Person.new.this":8;
    arg "Person.new.#tempcopy":8;
    var "@rf":1;
    clrf "@rf";
    push "Person.new.#tempcopy";
    push size(0);
    add size;
    load 8;
    push "Person.new.this";
    push size(0);
    add size;
    store 8;
    pop 8;
    push "Person.new.this";
    push size(8);
    add size;
    push "Person.new.#tempcopy";
    push size(8);
    add size;
    push &"Age.new(ref ptr Age,ref ptr Age):std.null <method>";
    call;
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Person.new.#scope4";
    jmp "#end_function";
"#no_return_exit_Person.new.#scope4":
"#end_function":
}
func[autogen] "Person.delete(ref ptr Person):std.null <method>":0
{
    arg "Person.delete.this":8;
    var "@rf":1;
    clrf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Person.delete.#scope5";
    jmp "#end_function";
"#no_return_exit_Person.delete.#scope5":
"#end_function":
    push "Person.delete.this";
    push size(8);
    add size;
    push &"Age.delete(ref ptr Age):std.null <method>";
    call;
}
func[autogen] "Person.operator=(ref ptr Person,ref ptr Person):ref ptr Person <method>":8
{
    arg "Person.operator=.this":8;
    arg "Person.operator=.#tempcopy":8;
    var "@rf":1;
    clrf "@rf";
    push "Person.operator=.#tempcopy";
    push size(0);
    add size;
    load 8;
    push "Person.operator=.this";
    push size(0);
    add size;
    store 8;
    pop 8;
    allocs 8;
    push "Person.operator=.this";
    push size(8);
    add size;
    push "Person.operator=.#tempcopy";
    push size(8);
    add size;
    push &"Age.operator=(ref ptr Age,ref ptr Age):ref ptr Age <method>";
    call;
    load 4;
    pop 4;
    push "Person.operator=.this";
    push &"@ret";
    store 8;
    pop 8;
    setf "@rf";
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_Person.operator=.#scope6";
    jmp "#end_function";
"#no_return_exit_Person.operator=.#scope6":
"#end_function":
}
func "operator<<(ref ptr std.ostream,ref ptr Person):ref ptr std.ostream":8
{
    arg "operator<<.o":8;
    arg "operator<<.a":8;
    var "@rf":1;
    var "#tempreturn_Age6":4;
    clrf "@rf";
    allocs 8;
    allocs 8;
    allocs 8;
    allocs 8;
    push "operator<<.o";
    allocs 8;
    push "operator<<.a";
    push &"Person.name(ref ptr Person):ptr std.char <method>";
    call;
    push &"std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream";
    call;
    push &"#global.script.pc0";
    push &"std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream";
    call;
    push &"#tempreturn_Age6";
    push "operator<<.a";
    push &"Person.age(ref ptr Person):Age <method>";
    call;
    push &"operator<<(ref ptr std.ostream,ref ptr Age):ref ptr std.ostream";
    call;
    push &"#global.script.pc1";
    push &"std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream";
    call;
    push &"@ret";
    store 8;
    pop 8;
    setf "@rf";
    push &"#tempreturn_Age6";
    push &"Age.delete(ref ptr Age):std.null <method>";
    call;
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_operator<<.#scope0";
    jmp "#end_function";
"#no_return_exit_operator<<.#scope0":
"#end_function":
}
func "main():std.null":0
{
    var "@rf":1;
    var "#temp_Age7":4;
    var "#temp_Person8":12;
    clrf "@rf";
    allocs 8;
    allocs 8;
    allocs 8;
    push &"std.out():ref ptr std.ostream";
    call;
    push &"#temp_Person8";
    push &"#global.script.pc2";
    allocs 4;
    push sp;
    push &"#temp_Age7";
    push int(44);
    push &"Age.new(ref ptr Age,std.int):std.null <method>";
    call;
    push &"#temp_Age7";
    push &"Age.new(ref ptr Age,ref ptr Age):std.null <method>";
    call;
    push &"Person.new(ref ptr Person,ptr std.char,Age):std.null <method>";
    call;
    push &"#temp_Person8";
    push &"operator<<(ref ptr std.ostream,ref ptr Person):ref ptr std.ostream";
    call;
    push &"#global.script.pc3";
    push &"std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream";
    call;
    load 0;
    push &"#temp_Age7";
    push &"Age.delete(ref ptr Age):std.null <method>";
    call;
    push &"#temp_Person8";
    push &"Person.delete(ref ptr Person):std.null <method>";
    call;
    push &"@rf";
    load 1;
    jmp ifz "#no_return_exit_main.#scope0";
    jmp "#end_function";
"#no_return_exit_main.#scope0":
"#end_function":
}

pi.exe then turns this file into a binary .po which is the bytecode for Pv with some additional linker information.

pl.exe is the linker. You feed it a bunch of .po files and it produces a .px file which Pv can run. The linker makes sure that functions or globals that are not used by the program are not included.

Working with all this is handled by pb.exe which is a sort of custom batch processor which can also run unit tests. In this case, this is the current .bat that is run by Pb when I'm doing a full test:

#echo off
test ../unittests

echo on
pc -I=../lib script.pc script.pi
pi script.pi script.po
pl -trim out.px script.po ../lib/stdlib.po ../lib/stdios.po
pd out.px
pv out.px

pd.exe is the disassembler. Disassembling the out.px from this example produces this monstrosity (in Pv bytecode):

== disassemble out.px ==================================================================================================
prologue
{
-- program prologue ----------------------------------------------------------------------------------------------------
 0:   setri dx 122,10,0,0,0,0,0,0
10:    call dx
-- terminate -----------------------------------------------------------------------------------------------------------
12:     end 
-- end -----------------------------------------------------------------------------------------------------------------
}
== #global.script.pc1 ==================================================================================================
var #global.script.pc1:11
13: 32,121,101,97,114,115,32,111,108,100,0
== #global.script.pc3 ==================================================================================================
var #global.script.pc3:3
24: 46,10,0
== #global.script.pc2 ==================================================================================================
var #global.script.pc2:5
27: 80,97,117,108,0
== #global.script.pc0 ==================================================================================================
var #global.script.pc0:5
32: 32,105,115,32,0
== instance ============================================================================================================
var instance:0
37: 
== Age.new(ref ptr Age,std.int):std.null <method> ======================================================================
func Age.new(ref ptr Age,std.int):std.null <method>:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
 37:   pushr bp
 39:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
 42:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
 52:  copyrr bp dx
 55:   subri dx 1
 65:  copyai dx 1 0
-- push Age.new.v ------------------------------------------------------------------------------------------------------
 76:  copyrr bp dx
 79:   addri dx 16
 89:   subri sp 4
 99:  copyaa dx sp 4
-- push Age.new.this ---------------------------------------------------------------------------------------------------
110:  copyrr bp dx
113:   addri dx 20
123:   subri sp 8
133:  copyaa dx sp 8
-- push size(0) --------------------------------------------------------------------------------------------------------
144:   subri sp 8
154:  copyai sp 8 0,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
172:     add size
-- store 4 -------------------------------------------------------------------------------------------------------------
174:    popr dx
176:  copyaa sp dx 4
-- pop 4 ---------------------------------------------------------------------------------------------------------------
187:   addri sp 4
-- push &@rf -----------------------------------------------------------------------------------------------------------
197:  copyrr bp dx
200:   subri dx 1
210:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
212:    popr dx
214:   subri sp 1
224:  copyaa dx sp 1
-- jmp ifz #no_return_exit_Age.new.#scope4 -----------------------------------------------------------------------------
235:    jmpz  10
244:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
254:   addri pc 0
-- label #no_return_exit_Age.new.#scope4 -------------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
264:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
274:    popr bp
276:     ret 12
-- end func Age.new(ref ptr Age,std.int):std.null <method> -------------------------------------------------------------
}
== Age.new(ref ptr Age,ref ptr Age):std.null <method> ==================================================================
func Age.new(ref ptr Age,ref ptr Age):std.null <method>:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
285:   pushr bp
287:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
290:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
300:  copyrr bp dx
303:   subri dx 1
313:  copyai dx 1 0
-- push Age.new.#tempcopy ----------------------------------------------------------------------------------------------
324:  copyrr bp dx
327:   addri dx 16
337:   subri sp 8
347:  copyaa dx sp 8
-- push size(0) --------------------------------------------------------------------------------------------------------
358:   subri sp 8
368:  copyai sp 8 0,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
386:     add size
-- load 4 --------------------------------------------------------------------------------------------------------------
388:    popr dx
390:   subri sp 4
400:  copyaa dx sp 4
-- push Age.new.this ---------------------------------------------------------------------------------------------------
411:  copyrr bp dx
414:   addri dx 24
424:   subri sp 8
434:  copyaa dx sp 8
-- push size(0) --------------------------------------------------------------------------------------------------------
445:   subri sp 8
455:  copyai sp 8 0,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
473:     add size
-- store 4 -------------------------------------------------------------------------------------------------------------
475:    popr dx
477:  copyaa sp dx 4
-- pop 4 ---------------------------------------------------------------------------------------------------------------
488:   addri sp 4
-- push &@rf -----------------------------------------------------------------------------------------------------------
498:  copyrr bp dx
501:   subri dx 1
511:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
513:    popr dx
515:   subri sp 1
525:  copyaa dx sp 1
-- jmp ifz #no_return_exit_Age.new.#scope5 -----------------------------------------------------------------------------
536:    jmpz  10
545:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
555:   addri pc 0
-- label #no_return_exit_Age.new.#scope5 -------------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
565:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
575:    popr bp
577:     ret 16
-- end func Age.new(ref ptr Age,ref ptr Age):std.null <method> ---------------------------------------------------------
}
== Age.delete(ref ptr Age):std.null <method> ===========================================================================
func Age.delete(ref ptr Age):std.null <method>:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
586:   pushr bp
588:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
591:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
601:  copyrr bp dx
604:   subri dx 1
614:  copyai dx 1 0
-- push &@rf -----------------------------------------------------------------------------------------------------------
625:  copyrr bp dx
628:   subri dx 1
638:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
640:    popr dx
642:   subri sp 1
652:  copyaa dx sp 1
-- jmp ifz #no_return_exit_Age.delete.#scope6 --------------------------------------------------------------------------
663:    jmpz  10
672:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
682:   addri pc 0
-- label #no_return_exit_Age.delete.#scope6 ----------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
692:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
702:    popr bp
704:     ret 8
-- end func Age.delete(ref ptr Age):std.null <method> ------------------------------------------------------------------
}
== operator<<(ref ptr std.ostream,ref ptr Age):ref ptr std.ostream =====================================================
func operator<<(ref ptr std.ostream,ref ptr Age):ref ptr std.ostream:8
{
-- function prologue ---------------------------------------------------------------------------------------------------
 713:   pushr bp
 715:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
 718:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
 728:  copyrr bp dx
 731:   subri dx 1
 741:  copyai dx 1 0
-- allocs 8 ------------------------------------------------------------------------------------------------------------
 752:   subri sp 8
-- push operator<<.o ---------------------------------------------------------------------------------------------------
 762:  copyrr bp dx
 765:   addri dx 24
 775:   subri sp 8
 785:  copyaa dx sp 8
-- push operator<<.a ---------------------------------------------------------------------------------------------------
 796:  copyrr bp dx
 799:   addri dx 16
 809:   subri sp 8
 819:  copyaa dx sp 8
-- push size(0) --------------------------------------------------------------------------------------------------------
 830:   subri sp 8
 840:  copyai sp 8 0,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
 858:     add size
-- load 4 --------------------------------------------------------------------------------------------------------------
 860:    popr dx
 862:   subri sp 4
 872:  copyaa dx sp 4
-- push &std.operator<<(ref ptr std.ostream,std.int):ref ptr std.ostream -----------------------------------------------
 883:   setri dx -18,12,0,0,0,0,0,0
 893:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
 895:    popr dx
 897:    call dx
-- push &@ret ----------------------------------------------------------------------------------------------------------
 899:  copyrr bp dx
 902:   addri dx 32
 912:   pushr dx
-- store 8 -------------------------------------------------------------------------------------------------------------
 914:    popr dx
 916:  copyaa sp dx 8
-- pop 8 ---------------------------------------------------------------------------------------------------------------
 927:   addri sp 8
-- setf @rf ------------------------------------------------------------------------------------------------------------
 937:  copyrr bp dx
 940:   subri dx 1
 950:  copyai dx 1 1
-- push &@rf -----------------------------------------------------------------------------------------------------------
 961:  copyrr bp dx
 964:   subri dx 1
 974:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
 976:    popr dx
 978:   subri sp 1
 988:  copyaa dx sp 1
-- jmp ifz #no_return_exit_operator<<.#scope0 --------------------------------------------------------------------------
 999:    jmpz  10
1008:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
1018:   addri pc 0
-- label #no_return_exit_operator<<.#scope0 ----------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
1028:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
1038:    popr bp
1040:     ret 16
-- end func operator<<(ref ptr std.ostream,ref ptr Age):ref ptr std.ostream --------------------------------------------
}
== Person.new(ref ptr Person,ptr std.char,Age):std.null <method> =======================================================
func Person.new(ref ptr Person,ptr std.char,Age):std.null <method>:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
1049:   pushr bp
1051:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
1054:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
1064:  copyrr bp dx
1067:   subri dx 1
1077:  copyai dx 1 0
-- push Person.new.n ---------------------------------------------------------------------------------------------------
1088:  copyrr bp dx
1091:   addri dx 20
1101:   subri sp 8
1111:  copyaa dx sp 8
-- push Person.new.this ------------------------------------------------------------------------------------------------
1122:  copyrr bp dx
1125:   addri dx 28
1135:   subri sp 8
1145:  copyaa dx sp 8
-- push size(0) --------------------------------------------------------------------------------------------------------
1156:   subri sp 8
1166:  copyai sp 8 0,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
1184:     add size
-- store 8 -------------------------------------------------------------------------------------------------------------
1186:    popr dx
1188:  copyaa sp dx 8
-- pop 8 ---------------------------------------------------------------------------------------------------------------
1199:   addri sp 8
-- push Person.new.this ------------------------------------------------------------------------------------------------
1209:  copyrr bp dx
1212:   addri dx 28
1222:   subri sp 8
1232:  copyaa dx sp 8
-- push size(8) --------------------------------------------------------------------------------------------------------
1243:   subri sp 8
1253:  copyai sp 8 8,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
1271:     add size
-- push &Person.new.a --------------------------------------------------------------------------------------------------
1273:  copyrr bp dx
1276:   addri dx 16
1286:   pushr dx
-- push &Age.new(ref ptr Age,ref ptr Age):std.null <method> ------------------------------------------------------------
1288:   setri dx 29,1,0,0,0,0,0,0
1298:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
1300:    popr dx
1302:    call dx
-- push &@rf -----------------------------------------------------------------------------------------------------------
1304:  copyrr bp dx
1307:   subri dx 1
1317:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
1319:    popr dx
1321:   subri sp 1
1331:  copyaa dx sp 1
-- jmp ifz #no_return_exit_Person.new.#scope1 --------------------------------------------------------------------------
1342:    jmpz  10
1351:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
1361:   addri pc 0
-- label #no_return_exit_Person.new.#scope1 ----------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- push &Person.new.a --------------------------------------------------------------------------------------------------
1371:  copyrr bp dx
1374:   addri dx 16
1384:   pushr dx
-- push &Age.delete(ref ptr Age):std.null <method> ---------------------------------------------------------------------
1386:   setri dx 74,2,0,0,0,0,0,0
1396:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
1398:    popr dx
1400:    call dx
-- free locals ---------------------------------------------------------------------------------------------------------
1402:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
1412:    popr bp
1414:     ret 20
-- end func Person.new(ref ptr Person,ptr std.char,Age):std.null <method> ----------------------------------------------
}
== Person.name(ref ptr Person):ptr std.char <method> ===================================================================
func Person.name(ref ptr Person):ptr std.char <method>:8
{
-- function prologue ---------------------------------------------------------------------------------------------------
1423:   pushr bp
1425:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
1428:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
1438:  copyrr bp dx
1441:   subri dx 1
1451:  copyai dx 1 0
-- push Person.name.this -----------------------------------------------------------------------------------------------
1462:  copyrr bp dx
1465:   addri dx 16
1475:   subri sp 8
1485:  copyaa dx sp 8
-- push size(0) --------------------------------------------------------------------------------------------------------
1496:   subri sp 8
1506:  copyai sp 8 0,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
1524:     add size
-- load 8 --------------------------------------------------------------------------------------------------------------
1526:    popr dx
1528:   subri sp 8
1538:  copyaa dx sp 8
-- push &@ret ----------------------------------------------------------------------------------------------------------
1549:  copyrr bp dx
1552:   addri dx 24
1562:   pushr dx
-- store 8 -------------------------------------------------------------------------------------------------------------
1564:    popr dx
1566:  copyaa sp dx 8
-- pop 8 ---------------------------------------------------------------------------------------------------------------
1577:   addri sp 8
-- setf @rf ------------------------------------------------------------------------------------------------------------
1587:  copyrr bp dx
1590:   subri dx 1
1600:  copyai dx 1 1
-- push &@rf -----------------------------------------------------------------------------------------------------------
1611:  copyrr bp dx
1614:   subri dx 1
1624:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
1626:    popr dx
1628:   subri sp 1
1638:  copyaa dx sp 1
-- jmp ifz #no_return_exit_Person.name.#scope2 -------------------------------------------------------------------------
1649:    jmpz  10
1658:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
1668:   addri pc 0
-- label #no_return_exit_Person.name.#scope2 ---------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
1678:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
1688:    popr bp
1690:     ret 8
-- end func Person.name(ref ptr Person):ptr std.char <method> ----------------------------------------------------------
}
== Person.age(ref ptr Person):Age <method> =============================================================================
func Person.age(ref ptr Person):Age <method>:4
{
-- function prologue ---------------------------------------------------------------------------------------------------
1699:   pushr bp
1701:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
1704:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
1714:  copyrr bp dx
1717:   subri dx 1
1727:  copyai dx 1 0
-- push &@ret ----------------------------------------------------------------------------------------------------------
1738:  copyrr bp dx
1741:   addri dx 24
1751:   pushr dx
-- load 8 --------------------------------------------------------------------------------------------------------------
1753:    popr dx
1755:   subri sp 8
1765:  copyaa dx sp 8
-- push Person.age.this ------------------------------------------------------------------------------------------------
1776:  copyrr bp dx
1779:   addri dx 16
1789:   subri sp 8
1799:  copyaa dx sp 8
-- push size(8) --------------------------------------------------------------------------------------------------------
1810:   subri sp 8
1820:  copyai sp 8 8,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
1838:     add size
-- push &Age.new(ref ptr Age,ref ptr Age):std.null <method> ------------------------------------------------------------
1840:   setri dx 29,1,0,0,0,0,0,0
1850:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
1852:    popr dx
1854:    call dx
-- setf @rf ------------------------------------------------------------------------------------------------------------
1856:  copyrr bp dx
1859:   subri dx 1
1869:  copyai dx 1 1
-- push &@rf -----------------------------------------------------------------------------------------------------------
1880:  copyrr bp dx
1883:   subri dx 1
1893:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
1895:    popr dx
1897:   subri sp 1
1907:  copyaa dx sp 1
-- jmp ifz #no_return_exit_Person.age.#scope3 --------------------------------------------------------------------------
1918:    jmpz  10
1927:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
1937:   addri pc 0
-- label #no_return_exit_Person.age.#scope3 ----------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
1947:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
1957:    popr bp
1959:     ret 8
-- end func Person.age(ref ptr Person):Age <method> --------------------------------------------------------------------
}
== Person.delete(ref ptr Person):std.null <method> =====================================================================
func Person.delete(ref ptr Person):std.null <method>:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
1968:   pushr bp
1970:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
1973:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
1983:  copyrr bp dx
1986:   subri dx 1
1996:  copyai dx 1 0
-- push &@rf -----------------------------------------------------------------------------------------------------------
2007:  copyrr bp dx
2010:   subri dx 1
2020:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
2022:    popr dx
2024:   subri sp 1
2034:  copyaa dx sp 1
-- jmp ifz #no_return_exit_Person.delete.#scope5 -----------------------------------------------------------------------
2045:    jmpz  10
2054:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
2064:   addri pc 0
-- label #no_return_exit_Person.delete.#scope5 -------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- push Person.delete.this ---------------------------------------------------------------------------------------------
2074:  copyrr bp dx
2077:   addri dx 16
2087:   subri sp 8
2097:  copyaa dx sp 8
-- push size(8) --------------------------------------------------------------------------------------------------------
2108:   subri sp 8
2118:  copyai sp 8 8,0,0,0,0,0,0,0
-- add size ------------------------------------------------------------------------------------------------------------
2136:     add size
-- push &Age.delete(ref ptr Age):std.null <method> ---------------------------------------------------------------------
2138:   setri dx 74,2,0,0,0,0,0,0
2148:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2150:    popr dx
2152:    call dx
-- free locals ---------------------------------------------------------------------------------------------------------
2154:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
2164:    popr bp
2166:     ret 8
-- end func Person.delete(ref ptr Person):std.null <method> ------------------------------------------------------------
}
== operator<<(ref ptr std.ostream,ref ptr Person):ref ptr std.ostream ==================================================
func operator<<(ref ptr std.ostream,ref ptr Person):ref ptr std.ostream:8
{
-- function prologue ---------------------------------------------------------------------------------------------------
2175:   pushr bp
2177:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
2180:   subri sp 5
-- clrf @rf ------------------------------------------------------------------------------------------------------------
2190:  copyrr bp dx
2193:   subri dx 1
2203:  copyai dx 1 0
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2214:   subri sp 8
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2224:   subri sp 8
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2234:   subri sp 8
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2244:   subri sp 8
-- push operator<<.o ---------------------------------------------------------------------------------------------------
2254:  copyrr bp dx
2257:   addri dx 24
2267:   subri sp 8
2277:  copyaa dx sp 8
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2288:   subri sp 8
-- push operator<<.a ---------------------------------------------------------------------------------------------------
2298:  copyrr bp dx
2301:   addri dx 16
2311:   subri sp 8
2321:  copyaa dx sp 8
-- push &Person.name(ref ptr Person):ptr std.char <method> -------------------------------------------------------------
2332:   setri dx -113,5,0,0,0,0,0,0
2342:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2344:    popr dx
2346:    call dx
-- push &std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream ------------------------------------------
2348:   setri dx -1,13,0,0,0,0,0,0
2358:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2360:    popr dx
2362:    call dx
-- push &#global.script.pc0 --------------------------------------------------------------------------------------------
2364:   setri dx 32,0,0,0,0,0,0,0
2374:   pushr dx
-- push &std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream ------------------------------------------
2376:   setri dx -1,13,0,0,0,0,0,0
2386:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2388:    popr dx
2390:    call dx
-- push &#tempreturn_Age6 ----------------------------------------------------------------------------------------------
2392:  copyrr bp dx
2395:   subri dx 5
2405:   pushr dx
-- push operator<<.a ---------------------------------------------------------------------------------------------------
2407:  copyrr bp dx
2410:   addri dx 16
2420:   subri sp 8
2430:  copyaa dx sp 8
-- push &Person.age(ref ptr Person):Age <method> -----------------------------------------------------------------------
2441:   setri dx -93,6,0,0,0,0,0,0
2451:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2453:    popr dx
2455:    call dx
-- push &operator<<(ref ptr std.ostream,ref ptr Age):ref ptr std.ostream -----------------------------------------------
2457:   setri dx -55,2,0,0,0,0,0,0
2467:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2469:    popr dx
2471:    call dx
-- push &#global.script.pc1 --------------------------------------------------------------------------------------------
2473:   setri dx 13,0,0,0,0,0,0,0
2483:   pushr dx
-- push &std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream ------------------------------------------
2485:   setri dx -1,13,0,0,0,0,0,0
2495:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2497:    popr dx
2499:    call dx
-- push &@ret ----------------------------------------------------------------------------------------------------------
2501:  copyrr bp dx
2504:   addri dx 32
2514:   pushr dx
-- store 8 -------------------------------------------------------------------------------------------------------------
2516:    popr dx
2518:  copyaa sp dx 8
-- pop 8 ---------------------------------------------------------------------------------------------------------------
2529:   addri sp 8
-- setf @rf ------------------------------------------------------------------------------------------------------------
2539:  copyrr bp dx
2542:   subri dx 1
2552:  copyai dx 1 1
-- push &#tempreturn_Age6 ----------------------------------------------------------------------------------------------
2563:  copyrr bp dx
2566:   subri dx 5
2576:   pushr dx
-- push &Age.delete(ref ptr Age):std.null <method> ---------------------------------------------------------------------
2578:   setri dx 74,2,0,0,0,0,0,0
2588:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2590:    popr dx
2592:    call dx
-- push &@rf -----------------------------------------------------------------------------------------------------------
2594:  copyrr bp dx
2597:   subri dx 1
2607:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
2609:    popr dx
2611:   subri sp 1
2621:  copyaa dx sp 1
-- jmp ifz #no_return_exit_operator<<.#scope0 --------------------------------------------------------------------------
2632:    jmpz  10
2641:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
2651:   addri pc 0
-- label #no_return_exit_operator<<.#scope0 ----------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
2661:   addri sp 5
-- function epilogue ---------------------------------------------------------------------------------------------------
2671:    popr bp
2673:     ret 16
-- end func operator<<(ref ptr std.ostream,ref ptr Person):ref ptr std.ostream -----------------------------------------
}
== main():std.null =====================================================================================================
func main():std.null:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
2682:   pushr bp
2684:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
2687:   subri sp 17
-- clrf @rf ------------------------------------------------------------------------------------------------------------
2697:  copyrr bp dx
2700:   subri dx 1
2710:  copyai dx 1 0
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2721:   subri sp 8
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2731:   subri sp 8
-- allocs 8 ------------------------------------------------------------------------------------------------------------
2741:   subri sp 8
-- push &std.out():ref ptr std.ostream ---------------------------------------------------------------------------------
2751:   setri dx 16,15,0,0,0,0,0,0
2761:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2763:    popr dx
2765:    call dx
-- push &#temp_Person8 -------------------------------------------------------------------------------------------------
2767:  copyrr bp dx
2770:   subri dx 17
2780:   pushr dx
-- push &#global.script.pc2 --------------------------------------------------------------------------------------------
2782:   setri dx 27,0,0,0,0,0,0,0
2792:   pushr dx
-- allocs 4 ------------------------------------------------------------------------------------------------------------
2794:   subri sp 4
-- push sp -------------------------------------------------------------------------------------------------------------
2804:   pushr sp
-- push &#temp_Age7 ----------------------------------------------------------------------------------------------------
2806:  copyrr bp dx
2809:   subri dx 5
2819:   pushr dx
-- push int(44) --------------------------------------------------------------------------------------------------------
2821:   subri sp 4
2831:  copyai sp 4 44,0,0,0
-- push &Age.new(ref ptr Age,std.int):std.null <method> ----------------------------------------------------------------
2845:   setri dx 37,0,0,0,0,0,0,0
2855:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2857:    popr dx
2859:    call dx
-- push &#temp_Age7 ----------------------------------------------------------------------------------------------------
2861:  copyrr bp dx
2864:   subri dx 5
2874:   pushr dx
-- push &Age.new(ref ptr Age,ref ptr Age):std.null <method> ------------------------------------------------------------
2876:   setri dx 29,1,0,0,0,0,0,0
2886:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2888:    popr dx
2890:    call dx
-- push &Person.new(ref ptr Person,ptr std.char,Age):std.null <method> -------------------------------------------------
2892:   setri dx 25,4,0,0,0,0,0,0
2902:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2904:    popr dx
2906:    call dx
-- push &#temp_Person8 -------------------------------------------------------------------------------------------------
2908:  copyrr bp dx
2911:   subri dx 17
2921:   pushr dx
-- push &operator<<(ref ptr std.ostream,ref ptr Person):ref ptr std.ostream --------------------------------------------
2923:   setri dx 127,8,0,0,0,0,0,0
2933:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2935:    popr dx
2937:    call dx
-- push &#global.script.pc3 --------------------------------------------------------------------------------------------
2939:   setri dx 24,0,0,0,0,0,0,0
2949:   pushr dx
-- push &std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream ------------------------------------------
2951:   setri dx -1,13,0,0,0,0,0,0
2961:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
2963:    popr dx
2965:    call dx
-- load 0 --------------------------------------------------------------------------------------------------------------
2967:    popr dx
2969:   subri sp 0
2979:  copyaa dx sp 0
-- push &#temp_Age7 ----------------------------------------------------------------------------------------------------
2990:  copyrr bp dx
2993:   subri dx 5
3003:   pushr dx
-- push &Age.delete(ref ptr Age):std.null <method> ---------------------------------------------------------------------
3005:   setri dx 74,2,0,0,0,0,0,0
3015:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
3017:    popr dx
3019:    call dx
-- push &#temp_Person8 -------------------------------------------------------------------------------------------------
3021:  copyrr bp dx
3024:   subri dx 17
3034:   pushr dx
-- push &Person.delete(ref ptr Person):std.null <method> ---------------------------------------------------------------
3036:   setri dx -80,7,0,0,0,0,0,0
3046:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
3048:    popr dx
3050:    call dx
-- push &@rf -----------------------------------------------------------------------------------------------------------
3052:  copyrr bp dx
3055:   subri dx 1
3065:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
3067:    popr dx
3069:   subri sp 1
3079:  copyaa dx sp 1
-- jmp ifz #no_return_exit_main.#scope0 --------------------------------------------------------------------------------
3090:    jmpz  10
3099:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
3109:   addri pc 0
-- label #no_return_exit_main.#scope0 ----------------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
3119:   addri sp 17
-- function epilogue ---------------------------------------------------------------------------------------------------
3129:    popr bp
3131:     ret 0
-- end func main():std.null --------------------------------------------------------------------------------------------
}
== std.print(std.int):std.null =========================================================================================
func std.print(std.int):std.null:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
3140:   pushr bp
3142:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
3145:   subri sp 0
-- push std.print.i ----------------------------------------------------------------------------------------------------
3155:  copyrr bp dx
3158:   addri dx 16
3168:   subri sp 4
3178:  copyaa dx sp 4
-- svc 1 ---------------------------------------------------------------------------------------------------------------
3189: service 1
-- pop 4 ---------------------------------------------------------------------------------------------------------------
3194:   addri sp 4
-- free locals ---------------------------------------------------------------------------------------------------------
3204:   addri sp 0
-- function epilogue ---------------------------------------------------------------------------------------------------
3214:    popr bp
3216:     ret 4
-- end func std.print(std.int):std.null --------------------------------------------------------------------------------
}
== std.print(ptr std.char):std.null ====================================================================================
func std.print(ptr std.char):std.null:0
{
-- function prologue ---------------------------------------------------------------------------------------------------
3225:   pushr bp
3227:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
3230:   subri sp 0
-- push std.print.i ----------------------------------------------------------------------------------------------------
3240:  copyrr bp dx
3243:   addri dx 16
3253:   subri sp 8
3263:  copyaa dx sp 8
-- svc 3 ---------------------------------------------------------------------------------------------------------------
3274: service 3
-- pop 8 ---------------------------------------------------------------------------------------------------------------
3279:   addri sp 8
-- free locals ---------------------------------------------------------------------------------------------------------
3289:   addri sp 0
-- function epilogue ---------------------------------------------------------------------------------------------------
3299:    popr bp
3301:     ret 8
-- end func std.print(ptr std.char):std.null ---------------------------------------------------------------------------
}
== std.operator<<(ref ptr std.ostream,std.int):ref ptr std.ostream =====================================================
func std.operator<<(ref ptr std.ostream,std.int):ref ptr std.ostream:8
{
-- function prologue ---------------------------------------------------------------------------------------------------
3310:   pushr bp
3312:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
3315:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
3325:  copyrr bp dx
3328:   subri dx 1
3338:  copyai dx 1 0
-- push std.operator<<.v -----------------------------------------------------------------------------------------------
3349:  copyrr bp dx
3352:   addri dx 16
3362:   subri sp 4
3372:  copyaa dx sp 4
-- push &std.print(std.int):std.null -----------------------------------------------------------------------------------
3383:   setri dx 68,12,0,0,0,0,0,0
3393:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
3395:    popr dx
3397:    call dx
-- push std.operator<<.o -----------------------------------------------------------------------------------------------
3399:  copyrr bp dx
3402:   addri dx 20
3412:   subri sp 8
3422:  copyaa dx sp 8
-- push &@ret ----------------------------------------------------------------------------------------------------------
3433:  copyrr bp dx
3436:   addri dx 28
3446:   pushr dx
-- store 8 -------------------------------------------------------------------------------------------------------------
3448:    popr dx
3450:  copyaa sp dx 8
-- pop 8 ---------------------------------------------------------------------------------------------------------------
3461:   addri sp 8
-- setf @rf ------------------------------------------------------------------------------------------------------------
3471:  copyrr bp dx
3474:   subri dx 1
3484:  copyai dx 1 1
-- push &@rf -----------------------------------------------------------------------------------------------------------
3495:  copyrr bp dx
3498:   subri dx 1
3508:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
3510:    popr dx
3512:   subri sp 1
3522:  copyaa dx sp 1
-- jmp ifz #no_return_exit_std.operator<<.#scope0 ----------------------------------------------------------------------
3533:    jmpz  10
3542:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
3552:   addri pc 0
-- label #no_return_exit_std.operator<<.#scope0 ------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
3562:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
3572:    popr bp
3574:     ret 12
-- end func std.operator<<(ref ptr std.ostream,std.int):ref ptr std.ostream --------------------------------------------
}
== std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream ================================================
func std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream:8
{
-- function prologue ---------------------------------------------------------------------------------------------------
3583:   pushr bp
3585:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
3588:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
3598:  copyrr bp dx
3601:   subri dx 1
3611:  copyai dx 1 0
-- push std.operator<<.v -----------------------------------------------------------------------------------------------
3622:  copyrr bp dx
3625:   addri dx 16
3635:   subri sp 8
3645:  copyaa dx sp 8
-- push &std.print(ptr std.char):std.null ------------------------------------------------------------------------------
3656:   setri dx -103,12,0,0,0,0,0,0
3666:   pushr dx
-- call ----------------------------------------------------------------------------------------------------------------
3668:    popr dx
3670:    call dx
-- push std.operator<<.o -----------------------------------------------------------------------------------------------
3672:  copyrr bp dx
3675:   addri dx 24
3685:   subri sp 8
3695:  copyaa dx sp 8
-- push &@ret ----------------------------------------------------------------------------------------------------------
3706:  copyrr bp dx
3709:   addri dx 32
3719:   pushr dx
-- store 8 -------------------------------------------------------------------------------------------------------------
3721:    popr dx
3723:  copyaa sp dx 8
-- pop 8 ---------------------------------------------------------------------------------------------------------------
3734:   addri sp 8
-- setf @rf ------------------------------------------------------------------------------------------------------------
3744:  copyrr bp dx
3747:   subri dx 1
3757:  copyai dx 1 1
-- push &@rf -----------------------------------------------------------------------------------------------------------
3768:  copyrr bp dx
3771:   subri dx 1
3781:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
3783:    popr dx
3785:   subri sp 1
3795:  copyaa dx sp 1
-- jmp ifz #no_return_exit_std.operator<<.#scope0 ----------------------------------------------------------------------
3806:    jmpz  10
3815:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
3825:   addri pc 0
-- label #no_return_exit_std.operator<<.#scope0 ------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
3835:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
3845:    popr bp
3847:     ret 16
-- end func std.operator<<(ref ptr std.ostream,ptr std.char):ref ptr std.ostream ---------------------------------------
}
== std.out():ref ptr std.ostream =======================================================================================
func std.out():ref ptr std.ostream:8
{
-- function prologue ---------------------------------------------------------------------------------------------------
3856:   pushr bp
3858:  copyrr sp bp
-- allocate locals -----------------------------------------------------------------------------------------------------
3861:   subri sp 1
-- clrf @rf ------------------------------------------------------------------------------------------------------------
3871:  copyrr bp dx
3874:   subri dx 1
3884:  copyai dx 1 0
-- push &instance ------------------------------------------------------------------------------------------------------
3895:   setri dx 37,0,0,0,0,0,0,0
3905:   pushr dx
-- push &@ret ----------------------------------------------------------------------------------------------------------
3907:  copyrr bp dx
3910:   addri dx 16
3920:   pushr dx
-- store 8 -------------------------------------------------------------------------------------------------------------
3922:    popr dx
3924:  copyaa sp dx 8
-- pop 8 ---------------------------------------------------------------------------------------------------------------
3935:   addri sp 8
-- setf @rf ------------------------------------------------------------------------------------------------------------
3945:  copyrr bp dx
3948:   subri dx 1
3958:  copyai dx 1 1
-- push &@rf -----------------------------------------------------------------------------------------------------------
3969:  copyrr bp dx
3972:   subri dx 1
3982:   pushr dx
-- load 1 --------------------------------------------------------------------------------------------------------------
3984:    popr dx
3986:   subri sp 1
3996:  copyaa dx sp 1
-- jmp ifz #no_return_exit_std.out.#scope0 -----------------------------------------------------------------------------
4007:    jmpz  10
4016:   addri pc 10
-- jmp #end_function ---------------------------------------------------------------------------------------------------
4026:   addri pc 0
-- label #no_return_exit_std.out.#scope0 -------------------------------------------------------------------------------
-- label #end_function -------------------------------------------------------------------------------------------------
-- free locals ---------------------------------------------------------------------------------------------------------
4036:   addri sp 1
-- function epilogue ---------------------------------------------------------------------------------------------------
4046:    popr bp
4048:     ret 0
-- end func std.out():ref ptr std.ostream ------------------------------------------------------------------------------
}

Pahahaha. I'm sure you followed all of that :)

Crappy explanation but I'd like to start blogging about this project again.

Hope you are all well. I'll try to catch up on JournalLand (remember when it was called that, eh?) when I can.



3 Comments


Recommended Comments

Welcome back Aardvajk - Always enjoy reading your posts.

Is this project available online anywhere out of interest?

Do you have overarching goals in mind for what the language is intended for? If I had to guess I would say it's a "simplified C++" so sort of similar to the goal of Java or C#.

Share this comment


Link to comment
1 hour ago, dmatter said:

Welcome back Aardvajk - Always enjoy reading your posts.

Is this project available online anywhere out of interest?

Do you have overarching goals in mind for what the language is intended for? If I had to guess I would say it's a "simplified C++" so sort of similar to the goal of Java or C#.

Hey dmatter! There is a name from the distant past. Great to see you are still here.

I finally grew up enough to start using GitHub :)

https://github.com/Aardvajk?tab=repositories

This project is everything under Px and the pcx support library. Terrible names but my name is Paul so it sort of makes sense to me at least.

I've fallen madly in love with the visitor pattern for writing compilers. It is such a pleasure to code in this way.

But yeah, everything is on there to peruse. Great to hear from you. Hope your life is good too.

(The IR is HORRIBLY unoptimised by the way. Taking the approach of getting it working first then revisiting that later. The only optimisation I have implemented is turning var a = foo() into var a:foo() in the Transform stage)

Edited by Aardvajk

Share this comment


Link to comment

Goals? Well, when you are effectively trying to reinvent C++ in C++, it seems important to remember that you are absolutely nuts and that this is purely a project for fun.

No goals at all other than keeping my free time occupied :)

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!