mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-10-18 07:24:16 +00:00
Apple /// PLASMA WIP
This commit is contained in:
parent
45bd973607
commit
c1aa4afa4c
@ -1,31 +0,0 @@
|
|||||||
;
|
|
||||||
; 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
|
|
24
src/cmd.pla
24
src/cmd.pla
@ -167,11 +167,9 @@ asm syscall
|
|||||||
INX
|
INX
|
||||||
LDA ESTKL,X
|
LDA ESTKL,X
|
||||||
STA CMD
|
STA CMD
|
||||||
STX ESP
|
|
||||||
JSR $BF00
|
JSR $BF00
|
||||||
CMD: !BYTE 00
|
CMD: !BYTE 00
|
||||||
PARAMS: !WORD 0000
|
PARAMS: !WORD 0000
|
||||||
LDX ESP
|
|
||||||
STA ESTKL,X
|
STA ESTKL,X
|
||||||
LDY #$00
|
LDY #$00
|
||||||
STY ESTKH,X
|
STY ESTKH,X
|
||||||
@ -1018,7 +1016,7 @@ def adddef(bank, addr, deflast)
|
|||||||
end
|
end
|
||||||
def loadmod(mod)
|
def loadmod(mod)
|
||||||
word refnum, rdlen, modsize, bytecode, defofst, defcnt, init, fixup
|
word refnum, rdlen, modsize, bytecode, defofst, defcnt, init, fixup
|
||||||
word addr, defaddr, modaddr, modfix
|
word addr, defaddr, modaddr, modfix, modend
|
||||||
word deftbl, deflast
|
word deftbl, deflast
|
||||||
word moddep, rld, esd, sym
|
word moddep, rld, esd, sym
|
||||||
byte defbank, str[16], filename[64]
|
byte defbank, str[16], filename[64]
|
||||||
@ -1048,7 +1046,7 @@ def loadmod(mod)
|
|||||||
; Load module dependencies.
|
; Load module dependencies.
|
||||||
;
|
;
|
||||||
while ^moddep
|
while ^moddep
|
||||||
if lookupmod(moddep) == 0
|
if !lookupmod(moddep)
|
||||||
close(refnum)
|
close(refnum)
|
||||||
refnum = 0
|
refnum = 0
|
||||||
if loadmod(moddep) < 0
|
if loadmod(moddep) < 0
|
||||||
@ -1063,7 +1061,7 @@ def loadmod(mod)
|
|||||||
deftbl = allocheap(defcnt * 5 + 1)
|
deftbl = allocheap(defcnt * 5 + 1)
|
||||||
deflast = deftbl
|
deflast = deftbl
|
||||||
^deflast = 0
|
^deflast = 0
|
||||||
if refnum == 0
|
if !refnum
|
||||||
;
|
;
|
||||||
; Reset read pointer.
|
; Reset read pointer.
|
||||||
;
|
;
|
||||||
@ -1094,9 +1092,10 @@ def loadmod(mod)
|
|||||||
;
|
;
|
||||||
modfix = modaddr - modfix
|
modfix = modaddr - modfix
|
||||||
bytecode = defofst + modfix - MODADDR
|
bytecode = defofst + modfix - MODADDR
|
||||||
rld = modaddr + modsize ; Re-Locatable Directory
|
modend = modaddr + modsize
|
||||||
esd = rld ; Extern+Entry Symbol Directory
|
rld = modend ; Re-Locatable Directory
|
||||||
while ^esd <> $00 ; Scan to end of ESD
|
esd = rld ; Extern+Entry Symbol Directory
|
||||||
|
while !^esd ; Scan to end of ESD
|
||||||
esd = esd + 4
|
esd = esd + 4
|
||||||
loop
|
loop
|
||||||
esd = esd + 1
|
esd = esd + 1
|
||||||
@ -1106,6 +1105,7 @@ def loadmod(mod)
|
|||||||
if ^MACHID & $30 == $30
|
if ^MACHID & $30 == $30
|
||||||
defbank = 1
|
defbank = 1
|
||||||
defaddr = allocxheap(rld - bytecode)
|
defaddr = allocxheap(rld - bytecode)
|
||||||
|
modend = bytecode
|
||||||
else
|
else
|
||||||
defbank = 0
|
defbank = 0
|
||||||
defaddr = bytecode
|
defaddr = bytecode
|
||||||
@ -1173,11 +1173,11 @@ def loadmod(mod)
|
|||||||
; Move bytecode to AUX bank.
|
; Move bytecode to AUX bank.
|
||||||
;
|
;
|
||||||
memxcpy(0, defaddr, bytecode, modsize - (bytecode - modaddr))
|
memxcpy(0, defaddr, bytecode, modsize - (bytecode - modaddr))
|
||||||
;
|
|
||||||
; Free up the bytecode in main memory.
|
|
||||||
;
|
|
||||||
releaseheap(bytecode)
|
|
||||||
fin
|
fin
|
||||||
|
;
|
||||||
|
; Free up the end-of-module in main memory.
|
||||||
|
;
|
||||||
|
releaseheap(modend)
|
||||||
else
|
else
|
||||||
perr = perr | 0x100
|
perr = perr | 0x100
|
||||||
return -perr
|
return -perr
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
INTERP = $03D0
|
||||||
;*
|
;*
|
||||||
;* MOVE CMD DOWN TO $1000-$2000
|
;* MOVE CMD DOWN TO $1000-$2000
|
||||||
;*
|
;*
|
||||||
|
@ -509,7 +509,7 @@ void emit_def(char *name, int is_bytecode)
|
|||||||
{
|
{
|
||||||
//printf("%s%c\n", name, LBL);
|
//printf("%s%c\n", name, LBL);
|
||||||
if (is_bytecode)
|
if (is_bytecode)
|
||||||
printf("\tJSR $03D0\n");
|
printf("\tJSR\tINTERP\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void emit_codetag(int tag)
|
void emit_codetag(int tag)
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import STDLIB
|
|
||||||
predef puts
|
|
||||||
end
|
|
||||||
|
|
||||||
byte hellostr[] = "Hello, world.\n"
|
|
||||||
|
|
||||||
puts(@hellostr)
|
|
||||||
done
|
|
69
src/makefile
69
src/makefile
@ -2,8 +2,11 @@
|
|||||||
AFLAGS = -o $@
|
AFLAGS = -o $@
|
||||||
LFLAGS = -C default.cfg
|
LFLAGS = -C default.cfg
|
||||||
PLVM = plvm
|
PLVM = plvm
|
||||||
PLVM02 = PLVM02.SYS
|
PLVM02 = PLASMA.SYSTEM\#FF2000
|
||||||
CMD = CMD.SYS
|
PLVM03 = SOS.INTERP\#050000
|
||||||
|
CMD = CMD\#FF2000
|
||||||
|
ROD = ROD\#FE1000
|
||||||
|
HGR1 = HGR1\#FE1000
|
||||||
PLASM = plasm
|
PLASM = plasm
|
||||||
INCS = tokens.h symbols.h lex.h parse.h codegen.h
|
INCS = tokens.h symbols.h lex.h parse.h codegen.h
|
||||||
OBJS = plasm.c parse.o lex.o codegen.o
|
OBJS = plasm.c parse.o lex.o codegen.o
|
||||||
@ -17,15 +20,15 @@ TXTTYPE = .TXT
|
|||||||
#
|
#
|
||||||
# Image filetypes for CiderPress
|
# Image filetypes for CiderPress
|
||||||
#
|
#
|
||||||
#PLATYPE = \#ed0000
|
#RELTYPE = \#fe1000
|
||||||
#BINTYPE = \#060000
|
#BINTYPE = \#060000
|
||||||
#SYSTYPE = \#ff0000
|
#SYSTYPE = \#ff2000
|
||||||
#TXTTYPE = \#040000
|
#TXTTYPE = \#040000
|
||||||
|
|
||||||
all: $(PLASM) $(PLVM) $(PLVM02) $(CMD) TESTLIB ROD.REL
|
all: $(PLASM) $(PLVM) $(PLVM02) $(PLVM03) $(CMD) $(ROD) $(HGR1)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm *.o *~ *.a *.SYM *.SYS *.REL TESTLIB $(PLASM) $(PLVM)
|
-rm *.o *~ *.a *.SYM $(CMD) *\#FE1000 $(ROD) $(HGR1) $(PLASM) $(PLVM)
|
||||||
|
|
||||||
$(PLASM): $(OBJS) $(INCS)
|
$(PLASM): $(OBJS) $(INCS)
|
||||||
cc $(OBJS) -o $(PLASM)
|
cc $(OBJS) -o $(PLASM)
|
||||||
@ -39,44 +42,34 @@ cmdexec.a: cmdexec.pla $(PLASM)
|
|||||||
$(PLVM02): plvm02.s cmdexec.a
|
$(PLVM02): plvm02.s cmdexec.a
|
||||||
acme -o $(PLVM02) -l PLVM02.SYM plvm02.s
|
acme -o $(PLVM02) -l PLVM02.SYM plvm02.s
|
||||||
|
|
||||||
$(CMD): cmd.pla cmdstub.s $(PLVM) $(PLASM)
|
soscmd.a: soscmd.pla $(PLASM)
|
||||||
|
./$(PLASM) -A < soscmd.pla > soscmd.a
|
||||||
|
|
||||||
|
$(PLVM03): plvm03.s soscmd.a
|
||||||
|
acme -o $(PLVM03) -l PLVM03.SYM plvm03.s
|
||||||
|
|
||||||
|
$(CMD): cmd.pla cmdstub.s $(PLVM02) $(PLASM)
|
||||||
./$(PLASM) -A < cmd.pla > cmd.a
|
./$(PLASM) -A < cmd.pla > cmd.a
|
||||||
acme --setpc 8192 -o $(CMD) cmdstub.s
|
acme --setpc 8192 -o $(CMD) cmdstub.s
|
||||||
|
|
||||||
TESTLIB: testlib.pla $(PLVM) $(PLASM)
|
test: test.pla testlib.pla $(PLVM) $(PLASM)
|
||||||
./$(PLASM) -AM < testlib.pla > testlib.a
|
|
||||||
acme --setpc 4094 -o TESTLIB testlib.a
|
|
||||||
|
|
||||||
test: test.pla TESTLIB $(PLVM) $(PLASM)
|
|
||||||
./$(PLASM) -AM < test.pla > test.a
|
./$(PLASM) -AM < test.pla > test.a
|
||||||
acme --setpc 4094 -o TEST.REL test.a
|
acme --setpc 4094 -o TEST#FE1000 test.a
|
||||||
./$(PLVM) TEST.REL
|
./$(PLASM) -AM < teslib.pla >testlib.a
|
||||||
|
acme --setpc 4094 -o TESTLIB#FE1000 testlib.a
|
||||||
|
./$(PLVM) TEST\#FE1000
|
||||||
|
|
||||||
TESTCLS: testcls.pla $(PLVM) $(PLASM)
|
$(ROD): rod.pla $(PLVM02) $(PLASM)
|
||||||
./$(PLASM) -AM < testcls.pla > testcls.a
|
|
||||||
acme --setpc 4094 -o TESTCLS testcls.a
|
|
||||||
|
|
||||||
class: class.pla TESTCLS $(PLVM) $(PLASM)
|
|
||||||
./$(PLASM) -AM < class.pla > class.a
|
|
||||||
acme --setpc 4094 -o CLASS.REL class.a
|
|
||||||
./$(PLVM) CLASS.REL
|
|
||||||
|
|
||||||
debug: test.pla TESTLIB $(PLVM) $(PLASM)
|
|
||||||
./$(PLASM) -AM < test.pla > test.a
|
|
||||||
acme --setpc 4094 -o TEST.REL test.a
|
|
||||||
./$(PLVM) -s TEST.REL MAIN
|
|
||||||
|
|
||||||
hello: hello.pla $(PLVM) $(PLASM)
|
|
||||||
./$(PLASM) -AM < hello.pla > hello.a
|
|
||||||
acme --setpc 4094 -o HELLO.REL hello.a
|
|
||||||
./$(PLVM) HELLO.REL
|
|
||||||
|
|
||||||
ROD.REL: rod.pla $(PLVM) $(PLASM)
|
|
||||||
./$(PLASM) -AM < rod.pla > rod.a
|
./$(PLASM) -AM < rod.pla > rod.a
|
||||||
acme --setpc 4094 -o ROD.REL rod.a
|
acme --setpc 4094 -o $(ROD) rod.a
|
||||||
|
|
||||||
HGR1: hgr1.pla hgr1test.pla $(PLVM) $(PLASM)
|
$(HGR1): hgr1.pla hgr1test.pla $(PLVM02) $(PLASM)
|
||||||
./$(PLASM) -AM < hgr1test.pla > hgr1test.a
|
./$(PLASM) -AM < hgr1test.pla > hgr1test.a
|
||||||
acme --setpc 4094 -o HGR1TEST.REL hgr1test.a
|
acme --setpc 4094 -o HGR1TEST.REL#FE1000 hgr1test.a
|
||||||
./$(PLASM) -AM < hgr1.pla > hgr1.a
|
./$(PLASM) -AM < hgr1.pla > hgr1.a
|
||||||
acme --setpc 4094 -o HGR1 hgr1.a
|
acme --setpc 4094 -o $(HGR1) hgr1.a
|
||||||
|
|
||||||
|
hello: hello.pla $(PLVM) $(PLASM)
|
||||||
|
m4 < hello.pla | ./$(PLASM) -AM > hello.a
|
||||||
|
acme --setpc 4094 -o HELLO#FE1000 hello.a
|
||||||
|
./$(PLVM) HELLO#FE1000
|
||||||
|
38
src/plvm02.s
38
src/plvm02.s
@ -209,8 +209,8 @@ PAGE3 = *
|
|||||||
;*
|
;*
|
||||||
;* PAGE 3 VECTORS INTO INTERPRETER
|
;* PAGE 3 VECTORS INTO INTERPRETER
|
||||||
;*
|
;*
|
||||||
BIT LCRDEN+LCBNK2 ; $03D0 - DIRECT INTERP ENTRY
|
INTERP BIT LCRDEN+LCBNK2 ; $03D0 - DIRECT INTERP ENTRY
|
||||||
JMP INTERP
|
JMP DINTERP
|
||||||
BIT LCRDEN+LCBNK2 ; $03D6 - INDIRECT INTERP ENTRY
|
BIT LCRDEN+LCBNK2 ; $03D6 - INDIRECT INTERP ENTRY
|
||||||
JMP IINTRP
|
JMP IINTRP
|
||||||
BIT LCRDEN+LCBNK2 ; $03DC - INDIRECT INTERPX ENTRY
|
BIT LCRDEN+LCBNK2 ; $03DC - INDIRECT INTERPX ENTRY
|
||||||
@ -306,7 +306,7 @@ DISABLE80 !BYTE 21, 13, '1', 26, 13
|
|||||||
;*
|
;*
|
||||||
;* ENTER INTO BYTECODE INTERPRETER
|
;* ENTER INTO BYTECODE INTERPRETER
|
||||||
;*
|
;*
|
||||||
INTERP BIT LCRWEN+LCBNK2 ; WRITE ENABLE LANGUAGE CARD
|
DINTERP BIT LCRWEN+LCBNK2 ; WRITE ENABLE LANGUAGE CARD
|
||||||
BIT LCRWEN+LCBNK2
|
BIT LCRWEN+LCBNK2
|
||||||
PLA
|
PLA
|
||||||
STA IPL
|
STA IPL
|
||||||
@ -384,10 +384,6 @@ TIMER JSR JMPTMR
|
|||||||
;*
|
;*
|
||||||
JMPTMR JMP (TMRVEC)
|
JMPTMR JMP (TMRVEC)
|
||||||
;*
|
;*
|
||||||
;* INDIRECT JUMP TO (TMP)
|
|
||||||
;*
|
|
||||||
JMPTMP JMP (TMP)
|
|
||||||
;*
|
|
||||||
;* ADD TOS TO TOS-1
|
;* ADD TOS TO TOS-1
|
||||||
;*
|
;*
|
||||||
ADD LDA ESTKL,X
|
ADD LDA ESTKL,X
|
||||||
@ -1818,17 +1814,17 @@ IBRNCHX LDA IPL
|
|||||||
;*
|
;*
|
||||||
CALL +INC_IP
|
CALL +INC_IP
|
||||||
LDA (IP),Y
|
LDA (IP),Y
|
||||||
STA TMPL
|
STA CALLADR+1
|
||||||
+INC_IP
|
+INC_IP
|
||||||
LDA (IP),Y
|
LDA (IP),Y
|
||||||
STA TMPH
|
STA CALLADR+2
|
||||||
LDA IPH
|
LDA IPH
|
||||||
PHA
|
PHA
|
||||||
LDA IPL
|
LDA IPL
|
||||||
PHA
|
PHA
|
||||||
TYA
|
TYA
|
||||||
PHA
|
PHA
|
||||||
JSR JMPTMP
|
CALLADR JSR $FFFF
|
||||||
PLA
|
PLA
|
||||||
TAY
|
TAY
|
||||||
PLA
|
PLA
|
||||||
@ -1841,10 +1837,10 @@ CALL +INC_IP
|
|||||||
;
|
;
|
||||||
CALLX +INC_IP
|
CALLX +INC_IP
|
||||||
LDA (IP),Y
|
LDA (IP),Y
|
||||||
STA TMPL
|
STA CALXADR+1
|
||||||
+INC_IP
|
+INC_IP
|
||||||
LDA (IP),Y
|
LDA (IP),Y
|
||||||
STA TMPH
|
STA CALXADR+2
|
||||||
LDA IPH
|
LDA IPH
|
||||||
PHA
|
PHA
|
||||||
LDA IPL
|
LDA IPL
|
||||||
@ -1853,7 +1849,7 @@ CALLX +INC_IP
|
|||||||
PHA
|
PHA
|
||||||
STA ALTRDOFF
|
STA ALTRDOFF
|
||||||
CLI
|
CLI
|
||||||
JSR JMPTMP
|
CALXADR JSR $FFFF
|
||||||
SEI
|
SEI
|
||||||
STA ALTRDON
|
STA ALTRDON
|
||||||
PLA
|
PLA
|
||||||
@ -1869,9 +1865,9 @@ CALLX +INC_IP
|
|||||||
;* INDIRECT CALL TO ADDRESS (NATIVE CODE)
|
;* INDIRECT CALL TO ADDRESS (NATIVE CODE)
|
||||||
;*
|
;*
|
||||||
ICAL LDA ESTKL,X
|
ICAL LDA ESTKL,X
|
||||||
STA TMPL
|
STA ICALADR+1
|
||||||
LDA ESTKH,X
|
LDA ESTKH,X
|
||||||
STA TMPH
|
STA ICALADR+2
|
||||||
INX
|
INX
|
||||||
LDA IPH
|
LDA IPH
|
||||||
PHA
|
PHA
|
||||||
@ -1879,7 +1875,7 @@ ICAL LDA ESTKL,X
|
|||||||
PHA
|
PHA
|
||||||
TYA
|
TYA
|
||||||
PHA
|
PHA
|
||||||
JSR JMPTMP
|
ICALADR JSR $FFFF
|
||||||
PLA
|
PLA
|
||||||
TAY
|
TAY
|
||||||
PLA
|
PLA
|
||||||
@ -1891,9 +1887,9 @@ ICAL LDA ESTKL,X
|
|||||||
JMP NEXTOP
|
JMP NEXTOP
|
||||||
;
|
;
|
||||||
ICALX LDA ESTKL,X
|
ICALX LDA ESTKL,X
|
||||||
STA TMPL
|
STA ICLXADR+1
|
||||||
LDA ESTKH,X
|
LDA ESTKH,X
|
||||||
STA TMPH
|
STA ICLXADR+2
|
||||||
INX
|
INX
|
||||||
LDA IPH
|
LDA IPH
|
||||||
PHA
|
PHA
|
||||||
@ -1903,7 +1899,7 @@ ICALX LDA ESTKL,X
|
|||||||
PHA
|
PHA
|
||||||
STA ALTRDOFF
|
STA ALTRDOFF
|
||||||
CLI
|
CLI
|
||||||
JSR JMPTMP
|
ICLXADR JSR $FFFF
|
||||||
SEI
|
SEI
|
||||||
STA ALTRDON
|
STA ALTRDON
|
||||||
PLA
|
PLA
|
||||||
@ -1952,7 +1948,7 @@ ENTER4 LDA ESTKH,X
|
|||||||
STA (IFP),Y
|
STA (IFP),Y
|
||||||
DEY
|
DEY
|
||||||
INX
|
INX
|
||||||
DEC TMPL
|
DEC NPARMS
|
||||||
BNE ENTER4
|
BNE ENTER4
|
||||||
ENTER5 LDY IPY
|
ENTER5 LDY IPY
|
||||||
JMP NEXTOP
|
JMP NEXTOP
|
||||||
@ -1992,7 +1988,7 @@ ENTERX4 LDA ESTKH,X
|
|||||||
STA (IFP),Y
|
STA (IFP),Y
|
||||||
DEY
|
DEY
|
||||||
INX
|
INX
|
||||||
DEC TMPL
|
DEC NPARMS
|
||||||
BNE ENTERX4
|
BNE ENTERX4
|
||||||
ENTERX5 STA ALTRDON
|
ENTERX5 STA ALTRDON
|
||||||
LDY IPY
|
LDY IPY
|
||||||
|
1016
src/plvm03.s
Normal file
1016
src/plvm03.s
Normal file
File diff suppressed because it is too large
Load Diff
1306
src/soscmd.pla
Normal file
1306
src/soscmd.pla
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
|||||||
;
|
|
||||||
; 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
|
|
Loading…
Reference in New Issue
Block a user