Initial class test

This commit is contained in:
David Schmenk 2014-05-22 09:02:23 -07:00
parent 25dd968f74
commit c097c0cfc4
4 changed files with 74 additions and 2 deletions

31
PLASMA/src/class.pla Executable file
View File

@ -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

View File

@ -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);

View File

@ -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

32
PLASMA/src/testcls.pla Executable file
View File

@ -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