Close

Assembler and Emulator Source Now Public

A project log for Trinity

A ternary LISP machine

john-sullyJohn Sully 12/19/2014 at 06:280 Comments

I uploaded the assembler and emulator source code to github. Try it out and let me know if it works for you. I omitted a build script as its only one .cpp file for each. The code was written and tested on windows, but as a simple console app it should work on any platform with little modification.

Try it out: https://github.com/JohnSully/Trinity

A disclaimer on the code: I wrote this quickly over the weekend and hacked it mercilsy to try new stuff. Its not the cleanest code but it works.


I also took some time to modify the jump instructions. JAF has now been replaced with JEQ, JEZ, and JMP. The new "ABC" program is much simpler:

; Outputs A,B,...,Z in a continuous loop
;Setup
Start:
    LIM    '@'    ; 'A'-1
Loop:    SWP
    LIM    1
    ADD
    OUT
;Check if done
    SWP
    LIM    'Z'
    SWP
    JEQ    Done
    JMP Loop
Done:    
    JMP Start
    

And assembled:

000000: 00+--+ 0+-+0+     ;LIM 0+-+0+ 
0000+-: 00+--0     ;SWP 
0000+0: 00+--+ 00000+     ;LIM 00000+ 
000+--: 0000+-     ;ADD 
000+-0: 00+-00     ;OUT 
000+-+: 00+--0     ;SWP 
000+0-: 00+--+ 0+0+00     ;LIM 0+0+00 
000+0+: 00+--0     ;SWP 
000++-: 000+-- 0000+-     ;JEQ Done[0]:(0000+-) 
000+++: 000+-+ 000---     ;JMP Loop[0]:(000---) 
00+--0: 000+-+ 00-+0+     ;JMP Start[0]:(00-+0+) 

Discussions