From b7659bdeaa104de119e5f57e66fb7e960762fa00 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Sat, 9 Nov 2019 13:34:51 -0800 Subject: [PATCH] Convert to ? DCG and it's macro-time! --- thun/compiler.markII.pl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/thun/compiler.markII.pl b/thun/compiler.markII.pl index 30c03c8..11e6f68 100644 --- a/thun/compiler.markII.pl +++ b/thun/compiler.markII.pl @@ -25,8 +25,11 @@ Mark II % Just do it in assembler. - -program([ % Mainloop. +⟐(program) --> + { [SP, EXPR_addr, TOS, TERM, EXPR, TermAddr, TEMP0, TEMP1, TEMP2, TEMP3] + = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] + }, + [ % Mainloop. word(0), % Zero root cell. do_offset(Reset), % Oberon bootloader writes MemLim to RAM[12] and allocate(_, 20), % stackOrg to RAM[24], we don't need these @@ -180,22 +183,30 @@ program([ % Mainloop. expr_cell(ConsSym, 0), label(ConsSym), symbol(Cons) -]) :- [SP, EXPR_addr, TOS, TERM, EXPR, TermAddr, TEMP0, TEMP1, TEMP2, TEMP3] - = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ]. +]. + +/* + +This stage ⟐//1 converts the intermediate representation to assembly +language. + +*/ + +⟐([]) --> []. +⟐([Term|Terms]) --> ⟐(Term), ⟐(Terms). - -do :- program(Program), - compile_program(Program, Binary), +do :- + compile_program(Binary), write_binary('joy_asmii.bin', Binary). -compile_program(ASM, Binary) :- +compile_program(Binary) :- + phrase(⟐(program), ASM), phrase(linker(ASM), EnumeratedASM), phrase(asm(EnumeratedASM), Binary). - /* Linker