From c097c0cfc435eb3b63c28b4a4f54e389e520d07e Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Thu, 22 May 2014 09:02:23 -0700 Subject: [PATCH] Initial class test --- PLASMA/src/class.pla | 31 +++++++++++++++++++++++++++++++ PLASMA/src/codegen.c | 4 ++-- PLASMA/src/makefile | 9 +++++++++ PLASMA/src/testcls.pla | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100755 PLASMA/src/class.pla create mode 100755 PLASMA/src/testcls.pla diff --git a/PLASMA/src/class.pla b/PLASMA/src/class.pla new file mode 100755 index 00000000..d5c7b43a --- /dev/null +++ b/PLASMA/src/class.pla @@ -0,0 +1,31 @@ +; +; Declare all imported modules and their data/functions. +; +import stdlib + predef putc, puts +end +import testcls + word print + const dec = 0 + const hex = 2 +end + +byte spaces[] = " " + +def putln + putc($0D) +end + +def printnums + word i + i = 10000 + repeat + print:dec(i) + puts(@spaces) + print:hex(i) + putln + i = i / 10 + until i == 0 +end +printnums +done diff --git a/PLASMA/src/codegen.c b/PLASMA/src/codegen.c index 489292e2..9b22cac8 100755 --- a/PLASMA/src/codegen.c +++ b/PLASMA/src/codegen.c @@ -470,7 +470,7 @@ int emit_data(int vartype, int consttype, long constval, int constsize) } else if (consttype & ADDR_TYPE) { - if (vartype == WORD_TYPE) + if (vartype & WORD_TYPE) { int fixup = fixup_new(constval, consttype, FIXUP_WORD); datasize = 2; @@ -491,7 +491,7 @@ int emit_data(int vartype, int consttype, long constval, int constsize) } else { - if (vartype == WORD_TYPE) + if (vartype & WORD_TYPE) { datasize = 2; printf("\t%s\t$%04lX\n", DW, constval & 0xFFFF); diff --git a/PLASMA/src/makefile b/PLASMA/src/makefile index 0bf35cc5..a61279ce 100755 --- a/PLASMA/src/makefile +++ b/PLASMA/src/makefile @@ -52,6 +52,15 @@ test: test.pla TESTLIB $(PLVM) $(PLASM) acme --setpc 4096 -o TEST.REL test.a ./$(PLVM) TEST.REL +TESTCLS: testcls.pla $(PLVM) $(PLASM) + ./$(PLASM) -AM < testcls.pla > testcls.a + acme --setpc 4096 -o TESTCLS testcls.a + +class: class.pla TESTCLS $(PLVM) $(PLASM) + ./$(PLASM) -AM < class.pla > class.a + acme --setpc 4096 -o CLASS.REL class.a + ./$(PLVM) CLASS.REL + debug: test.pla TESTLIB $(PLVM) $(PLASM) ./$(PLASM) -AM < test.pla > test.a acme --setpc 4096 -o TEST.REL test.a diff --git a/PLASMA/src/testcls.pla b/PLASMA/src/testcls.pla new file mode 100755 index 00000000..e2ae4d68 --- /dev/null +++ b/PLASMA/src/testcls.pla @@ -0,0 +1,32 @@ +; +; Declare all imported modules and their data/functions. +; +import stdlib + predef putc +end +predef puti, puth +export word print[] = @puti, @puth +byte valstr[] = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' +; +; Define functions. +; +def puti(i) + if i < 0 + putc('-') + i = -i + fin + if i < 10 + putc(i + '0') + else + puti(i / 10) + putc(i % 10 + '0') + fin +end +def puth(h) + putc('$') + putc(valstr[(h >> 12) & $0F]) + putc(valstr[(h >> 8) & $0F]) + putc(valstr[(h >> 4) & $0F]) + putc(valstr[ h & $0F]) +end +done