This commit is contained in:
Martin Haye 2014-06-13 13:10:45 -07:00
commit 44fdabab49
9 changed files with 259 additions and 502 deletions

View File

@ -16,26 +16,34 @@ const resxhgr2 = $0020
;
; Pedefined functions.
;
predef home, gotoxy, viewport, crout, cout, prstr, cin, rdstr
predef syscall, call
predef crout, cout, prstr, cin, rdstr
predef markheap, allocheap, allocalignheap, releaseheap, availheap
predef memset, memcpy
predef uword_isgt, uword_isge, uword_islt, uword_isle
predef loadmod, execmod
predef loadmod, execmod, lookupmod
;
; System variable.
;
word version = $0010 ; 00.10
word systemflags = 0
word heap
word xheap = $0800
word lastsym = symtbl
byte perr
word cmdptr
;
; Standard Library exported functions.
;
byte stdlibstr[] = "STDLIB"
byte machidstr[] = "MACHID"
byte clsstr[] = "CLS"
byte gotoxystr[] = "GOTOXY"
byte viewstr[] = "VIEWPORT"
byte sysstr[] = "SYSCALL"
byte callstr[] = "CALL"
byte putcstr[] = "PUTC"
byte putlnstr[] = "PUTLN"
byte putsstr[] = "PUTS"
byte getcstr[] = "GETC"
byte getsstr[] = "GETS"
byte sysstr[] = "SYSCALL"
byte callstr[] = "CALL"
byte hpmarkstr[] = "HEAPMARK"
byte hpalignstr[] = "HEAPALLOCALIGN"
byte hpallocstr[] = "HEAPALLOC"
@ -47,17 +55,16 @@ byte uisgtstr[] = "ISUGT"
byte uisgestr[] = "ISUGE"
byte uisltstr[] = "ISULT"
byte uislestr[] = "ISULE"
byte loadstr[] = "LOAD"
byte execstr[] = "EXEC"
word exports[] = @clsstr, @home
word = @gotoxystr, @gotoxy
word = @viewstr, @viewport
byte loadstr[] = "MODLOAD"
byte execstr[] = "MODEXEC"
byte modadrstr[] = "MODADDR"
word exports[] = @sysstr, @syscall
word = @callstr, @call
word = @putcstr, @cout
word = @putlnstr, @crout
word = @putsstr, @prstr
word = @getcstr, @cin
word = @getsstr, @rdstr
word = @sysstr, @syscall
word = @callstr, @call
word = @hpmarkstr, @markheap
word = @hpallocstr,@allocheap
word = @hpalignstr,@allocalignheap
@ -70,42 +77,24 @@ word = @uisltstr, @uword_islt
word = @uislestr, @uword_isle
word = @loadstr, @loadmod
word = @execstr, @execmod
word = @modadrstr, @lookupmod
word = @machidstr, MACHID
word = 0
word stdlibsym = @exports
;
; String pool.
;
byte version[] = "PLASMA 0.9\n"
byte autorun[] = "AUTORUN"
byte verstr[] = "PLASMA "
byte freestr[] = "MEM FREE:$"
byte errorstr[] = "ERR:$"
byte okstr[] = "OK"
byte huhstr[] = "?\n"
byte prefix[32] = ""
;
; System variable.
;
word heap
word lastsym = symtbl
word xheap = $0800
word systemflags = 0
byte perr
word cmdptr
;
; Utility functions
;
asm equates
;*
;* BANK SWITCHED MEM
;*
LCRDEN = $C080
LCWTEN = $C081
ROMEN = $C082
LCRWEN = $C083
LCBNK2 = $00
LCBNK1 = $08
!SOURCE "plvm02zp.inc"
end
;asm equates included from cmdstub.s
;
; CALL PRODOS
; SYSCALL(CMD, PARAMS)
@ -128,25 +117,25 @@ PARAMS: !WORD 0000
end
;
; CALL 6502 ROUTINE
; CALL(AREG, XREG, YREG, STATUS, ADDR)
; CALL(ADDR, AREG, XREG, YREG, STATUS)
;
asm call
REGVALS = SRC
PHP
LDA ESTKL,X
LDA ESTKL+4,X
STA TMPL
LDA ESTKH,X
LDA ESTKH+4,X
STA TMPH
INX
LDA ESTKL,X
PHA
INX
LDA ESTKL,X
TAY
INX
LDA ESTKL+1,X
TAY
LDA ESTKL+3,X
PHA
LDA ESTKL,X
LDA ESTKL+2,X
INX
INX
INX
INX
STX ESP
TAX
@ -174,11 +163,11 @@ end
; CALL LOADED SYSTEM PROGRAM
;
asm exec
LDA #$00
STA IFPL
LDX #$00
STX IFPL
LDA #$BF
STA IFPH
LDX #$FF
DEX
TXS
LDX #ESTKSZ/2
BIT ROMEN
@ -189,7 +178,7 @@ end
;
asm reboot
BIT ROMEN
DEC $3F4 ; INVALIDATE POWER-UP BYTE
DEC $03F4 ; INVALIDATE POWER-UP BYTE
JMP ($FFFC) ; RESET
end
;
@ -328,67 +317,6 @@ asm memxcpy
INX
RTS
end
;
; HOME
;
asm home
STX ESP
BIT ROMEN
JSR $FC58
BIT LCRDEN+LCBNK2
LDX ESP
DEX
RTS
end
;
; SET VIEWPORT
; VIEWPORT(LEFT, TOP, WIDTH, HEIGHT)
;
asm viewport
LDA ESTKL+1,X
BNE +
LDA ESTKL,X
BNE +
STA ESTKL+3,X
STA ESTKL+2,X
LDA #40
STA ESTKL+1,X
LDA #24
STA ESTKL,X
+ LDA ESTKL+3,X
STA $20
LDA ESTKL+1,X
STA $21
LDA ESTKL+2,X
STA $22
CLC
ADC ESTKL,X
STA $23
LDY #$00
STY $24
LDA $22
INX
INX
BNE VTAB
end
;
; SET VIEWPORT RELATIVE CURSOR POSITION
; GOTOXY(X,Y)
;
asm gotoxy
LDA ESTKL+1,X
STA $24
LDA ESTKL,X
CLC
ADC $22
VTAB STX ESP
BIT ROMEN
JSR $FB5B
BIT LCRDEN+LCBNK2
LDX ESP
INX
RTS
end
asm crout
DEX
LDA #$8D
@ -434,7 +362,6 @@ asm prstr
STA SRCL
LDA ESTKH,X
STA SRCH
STY ESTKH,X
LDA (SRC),Y
STA TMP
BEQ ++
@ -446,8 +373,7 @@ asm prstr
JSR TOUPR
+ ORA #$80
JSR $FDED
TYA
CMP TMP
CPY TMP
BNE -
BIT LCRDEN+LCBNK2
++ RTS
@ -468,12 +394,11 @@ end
; PRINT WORD
;
asm prword
LDA ESTKH,X
TAY
LDA ESTKL,X
STX ESP
TAX
TYA
TXA
TAY
LDA ESTKH,Y
LDX ESTKL,Y
BIT ROMEN
JSR $F941
LDX ESP
@ -496,8 +421,8 @@ asm rdstr
STA $01FF,X
DEX
BPL -
TXA
LDX ESP
LDA #$FF
STA ESTKL,X
LDA #$01
STA ESTKH,X
@ -531,28 +456,26 @@ asm uword_isle
RTS
end
asm uword_isgt
LDY #$FF
LDA ESTKL,X
CMP ESTKL+1,X
LDA ESTKH,X
SBC ESTKH+1,X
BCC +
INY
+ STY ESTKL+1,X
STY ESTKH+1,X
LDA #$FF
ADC #$00
STA ESTKL+1,X
STA ESTKH+1,X
INX
RTS
end
asm uword_islt
LDY #$FF
LDA ESTKL+1,X
CMP ESTKL,X
LDA ESTKH+1,X
SBC ESTKH,X
BCC +
INY
+ STY ESTKL+1,X
STY ESTKH+1,X
LDA #$FF
ADC #$00
STA ESTKL+1,X
STA ESTKH+1,X
INX
RTS
end
@ -649,8 +572,7 @@ TOUPR AND #$7F
BCC +
CMP #'z'+1
BCS +
SEC
SBC #$20
SBC #$1F
+ STA ESTKL,X
RTS
end
@ -885,16 +807,6 @@ def allocxheap(size)
fin
return xaddr
end
;def availxheap(void)
; return $BF00 - xheap;
;end
;def markxheap
; return xheap
;end
;def releasexheap(newxheap)
; xheap = newxheap;
; return $BF00 - xheap
;end
;
; DCI table routines,
;
@ -1032,7 +944,7 @@ def loadmod(mod)
close(refnum)
refnum = 0
if loadmod(moddep) < 0
return perr
return -perr
fin
fin
moddep = moddep + dcitos(moddep, @str)
@ -1070,6 +982,10 @@ def loadmod(mod)
until rdlen <= 0
close(refnum)
;
; Add module to symbol table.
;
addmod(mod, modaddr)
;
; Apply all fixups and symbol import/export.
;
modfix = modaddr - modfix
@ -1156,10 +1072,6 @@ def loadmod(mod)
;
memxcpy(defaddr, bytecode, modsize - (bytecode - modaddr))
fin
;
; Free up the end-of-module in main memory.
;
releaseheap(modend)
fin
if perr
return -perr
@ -1168,9 +1080,20 @@ def loadmod(mod)
; Call init routine if it exists.
;
if init
return adddef(defbank, init - defofst + defaddr, @deflast)()
fixup = adddef(defbank, init - defofst + defaddr, @deflast)()
if defbank
xheap = init - defofst + defaddr
else
modend = init - defofst + defaddr
fin
return 0
else
fixup = 0
fin
;
; Free up the end-of-module in main memory.
;
releaseheap(modend)
return fixup
end
;
; Command mode
@ -1350,17 +1273,34 @@ def execmod(modfile)
heap = saveheap
fin
end
;
; Get heap start.
;
heap = *freemem
;
; Init symbol table.
;
stodci(@stdlibstr, heap)
addmod(heap, 1)
addmod(heap, @systemflags)
while *stdlibsym
stodci((stdlibsym):0, heap)
addsym(heap, (stdlibsym):2)
stdlibsym = stdlibsym + 4
loop
;
; Try to run autorun module.
;
resetmemfiles()
prstr(@version)
execmod(@autorun)
perr = 0
;
; Print some startup info.
;
prstr(@verstr)
prbyte(version.1)
cout('.')
prbyte(version.0)
crout
prstr(@freestr)
prword(availheap)
crout

View File

@ -1,179 +0,0 @@
const iobuffer = $0800
const databuff = $0C00
const memmap = $BF58
const sysfile = $0280
byte syshalt[] = "SYSTEM HALTED..."
byte perr
;
; Utility functions
;
; CALL PRODOS
; SYSCALL(CMD, PARAMS)
;
asm prodos
LDA ESTKL,X
LDY ESTKH,X
STA PARAMS
STY PARAMS+1
INX
LDA ESTKL,X
STA CMD
STX ESP
JSR $BF00
CMD: !BYTE 00
PARAMS: !WORD 0000
LDX ESP
STA ESTKL,X
LDY #$00
STY ESTKH,X
RTS
end
;
; CALL LOADED SYSTEM PROGRAM
;
asm exec
LDA #$00
STA IFPL
LDA #$BF
STA IFPH
LDX #$FE
TXS
LDX #ESTKSZ/2
BIT ROMEN
JMP $2000
end
;
; EXIT
;
asm reboot
BIT ROMEN
LDA #$00
STA $3F4 ; INVALIDATE POWER-UP BYTE
JMP ($FFFC) ; RESET
end
;
; SET MEMORY TO 0
; MEMCLR(ADDR, SIZE)
;
asm memclr
LDY #$00
LDA ESTKL+1,X
STA DSTL
LDA ESTKH+1,X
STA DSTH
INC ESTKL,X
INC ESTKH,X
TYA
SETMLP DEC ESTKL,X
BNE +
DEC ESTKH,X
BEQ ++
+ STA (DST),Y
INY
BNE SETMLP
INC DSTH
BNE SETMLP
++ INX
RTS
end
asm cin
BIT ROMEN
STX ESP
JSR $FD0C
LDX ESP
DEX
STA ESTKL,X
LDY #$00
STY ESTKH,X
BIT LCRDEN+LCBNK2
RTS
end
;
; PRINT STRING
; PRSTR(STR)
;
asm prstr
LDY #$00
LDA ESTKL,X
STA SRCL
LDA ESTKH,X
STA SRCH
BIT ROMEN
LDA (SRC),Y
STA ESTKL,X
BEQ +
- INY
LDA (SRC),Y
ORA #$80
JSR $FDED
TYA
CMP ESTKL,X
BNE -
+ BIT LCRDEN+LCBNK2
RTS
end
;
; ProDOS routines
;
def open(path, buff)
byte params[6]
params.0 = 3
params:1 = path
params:3 = buff
params.5 = 0
perr = prodos($C8, @params)
return params.5
end
def close(refnum)
byte params[2]
params.0 = 1
params.1 = refnum
perr = prodos($CC, @params)
return perr
end
def read(refnum, buff, len)
byte params[8]
params.0 = 4
params.1 = refnum
params:2 = buff
params:4 = len
params:6 = 0
perr = prodos($CA, @params)
return params:6
end
def resetmemfiles
;
; Close all files
;
^$BFD8 = 0
close(0)
;
; Set memory bitmap
;
memclr(memmap, 24)
^memmap.0 = $CF
^memmap.23 = $01
end
def execsys
byte refnum
if ^sysfile
refnum = open(sysfile, iobuffer)
if refnum
if read(refnum, $2000, $FFFF)
resetmemfiles()
exec()
fin
fin
fin
end
resetmemfiles()
execsys
prstr(@syshalt)
cin()
reboot()
done

View File

@ -1,29 +1,45 @@
INTERP = $03D0
LCRDEN = $C080
LCWTEN = $C081
ROMEN = $C082
LCRWEN = $C083
LCBNK2 = $00
LCBNK1 = $08
!SOURCE "plvm02zp.inc"
;*
;* MOVE CMD DOWN TO $1000-$2000
;*
LDA #<_CMDBEGIN
STA $06
STA SRCL
LDA #>_CMDBEGIN
STA $07
LDA #$00
STA $08
LDA #$10
STA $09
STA SRCH
LDY #$00
- LDA ($06),Y
STA ($08),Y
STY DSTL
LDA #$10
STA DSTH
- LDA (SRC),Y
STA (DST),Y
INY
BNE -
INC $07
INC $09
LDA $09
CMP #$20
INC SRCH
INC DSTH
LDA DSTH
CMP #$20 ; STOP WHEN DST=$2000 REACHED
BNE -
LDA #<_CMDEND
STA $06
STA SRCL
LDA #>_CMDEND
STA $07
STA SRCH
;
; INIT VM ENVIRONMENT STACK POINTERS
;
LDA #$00 ; INIT FRAME POINTER
STA IFPL
LDA #$BF
STA IFPH
LDX #$FE ; INIT STACK POINTER (YES, $FE. SEE GETS)
TXS
LDX #ESTKSZ/2 ; INIT EVAL STACK INDEX
JMP $1000
_CMDBEGIN = *
!PSEUDOPC $1000 {

View File

@ -2,8 +2,8 @@
AFLAGS = -o $@
LFLAGS = -C default.cfg
PLVM = plvm
PLVM02 = PLVM02.SYS
CMD = CMD.SYS
PLVM02 = PLASMA.SYSTEM\#FF2000
CMD = CMD\#FF2000
PLASM = plasm
INCS = tokens.h symbols.h lex.h parse.h codegen.h
OBJS = plasm.c parse.o lex.o codegen.o
@ -22,10 +22,10 @@ TXTTYPE = .TXT
#SYSTYPE = \#ff0000
#TXTTYPE = \#040000
all: $(PLASM) $(PLVM) $(PLVM02) $(CMD) TESTLIB
all: $(PLASM) $(PLVM) $(PLVM02) $(CMD)
clean:
-rm *.o *~ *.a *.SYM *.SYS *.REL TESTLIB $(PLASM) $(PLVM)
-rm *.o *~ *.a *FE1000 $(PLVM02) $(CMD) $(PLASM) $(PLVM)
$(PLASM): $(OBJS) $(INCS)
cc $(OBJS) -o $(PLASM)
@ -33,31 +33,28 @@ $(PLASM): $(OBJS) $(INCS)
$(PLVM): plvm.c
cc plvm.c -o $(PLVM)
cmdexec.a: cmdexec.pla $(PLASM)
./$(PLASM) -A < cmdexec.pla > cmdexec.a
$(PLVM02): plvm02.s cmdexec.a
acme -o $(PLVM02) -l PLVM02.SYM plvm02.s
$(PLVM02): plvm02.s
acme -o $(PLVM02) plvm02.s
$(CMD): cmd.pla cmdstub.s $(PLVM) $(PLASM)
./$(PLASM) -A < cmd.pla > cmd.a
acme --setpc 8192 -o $(CMD) cmdstub.s
TESTLIB: testlib.pla $(PLVM) $(PLASM)
TESTLIB\#FE1000: testlib.pla $(PLVM) $(PLASM)
m4 < testlib.pla |./$(PLASM) -AM > testlib.a
acme --setpc 4094 -o TESTLIB testlib.a
acme --setpc 4094 -o TESTLIB\#FE1000 testlib.a
test: test.pla TESTLIB $(PLVM) $(PLASM)
test: test.pla TESTLIB\#FE1000 $(PLVM) $(PLASM)
m4 < test.pla | ./$(PLASM) -AM > test.a
acme --setpc 4094 -o TEST.REL test.a
./$(PLVM) TEST.REL
acme --setpc 4094 -o TEST\#FE1000 test.a
./$(PLVM) TEST
debug: test.pla TESTLIB $(PLVM) $(PLASM)
m4 < test.pla | ./$(PLASM) -AM > test.a
acme --setpc 4094 -o TEST.REL test.a
./$(PLVM) -s TEST.REL MAIN
acme --setpc 4094 -o TEST\#FE1000 test.a
./$(PLVM) -s TEST MAIN
hello: hello.pla $(PLVM) $(PLASM)
m4 < hello.pla | ./$(PLASM) -AM > hello.a
acme --setpc 4094 -o HELLO.REL hello.a
./$(PLVM) HELLO.REL
acme --setpc 4094 -o HELLO\#FE1000 hello.a
./$(PLVM) HELLO

View File

@ -146,6 +146,8 @@ uword lookup_tbl(byte *dci, byte *tbl)
while (*entry++ & 0x80);
entry += 2;
}
dcitos(dci, str);
printf("\nError: symbols %s not found in symbol table.\n", str);
return 0;
}
uword add_tbl(byte *dci, int val, byte **last)
@ -233,10 +235,12 @@ int load_mod(byte *mod)
byte *moddep, *rld, *esd, *cdd, *sym;
byte header[128];
int fd;
char filename[32], string[17];
char filename[48], string[17];
dcitos(mod, filename);
printf("Load module %s\n", filename);
if (strlen(filename) < 8 || (filename[strlen(filename) - 7] != '#'))
strcat(filename, "#FE1000");
fd = open(filename, O_RDONLY, 0);
if ((fd > 0) && (len = read(fd, header, 128)) > 0)
{
@ -316,6 +320,10 @@ int load_mod(byte *mod)
printf("Module def count: $%04X\n", defcnt);
printf("Module init: $%04X\n", init ? init + modfix - MOD_ADDR : 0);
}
/*
* Add module to symbol table.
*/
add_mod(mod, modaddr);
/*
* Print out the Re-Location Dictionary.
*/
@ -418,6 +426,7 @@ int load_mod(byte *mod)
if (init)
{
interp(mem_data + init + modfix - MOD_ADDR);
// release_heap(init + modfix - MOD_ADDR); // Free up init code
return POP;
}
return 0;
@ -429,6 +438,8 @@ void call(uword pc)
unsigned int i, s;
char c, sz[64];
if (show_state)
printf("\nCall code:$%02X\n", mem_data[pc]);
switch (mem_data[pc++])
{
case 0: // NULL call
@ -440,19 +451,14 @@ void call(uword pc)
case 2: // BYTECODE in mem_data
interp(mem_data + (mem_data[pc] + (mem_data[pc + 1] << 8)));
break;
case 3: // LIBRARY STDLIB::VIEWPORT
printf("Set Viewport %d, %d, %d, %d\n", esp[3], esp[2], esp[1], esp[0]);
esp += 4;
PUSH(0);
break;
case 4: // LIBRARY STDLIB::PUTC
case 3: // LIBRARY STDLIB::PUTC
c = POP;
if (c == 0x0D)
c = '\n';
putchar(c);
PUSH(0);
break;
case 5: // LIBRARY STDLIB::PUTS
case 4: // LIBRARY STDLIB::PUTS
s = POP;
i = mem_data[s++];
PUSH(i);
@ -464,7 +470,7 @@ void call(uword pc)
putchar(c);
}
break;
case 6: // LIBRARY STDLIB::PUTSZ
case 5: // LIBRARY STDLIB::PUTSZ
s = POP;
while ((c = mem_data[s++]))
{
@ -474,10 +480,10 @@ void call(uword pc)
}
PUSH(0);
break;
case 7: // LIBRARY STDLIB::GETC
case 6: // LIBRARY STDLIB::GETC
PUSH(getchar());
break;
case 8: // LIBRARY STDLIB::GETS
case 7: // LIBRARY STDLIB::GETS
gets(sz);
for (i = 0; sz[i]; i++)
mem_data[0x200 + i] = sz[i];
@ -485,25 +491,14 @@ void call(uword pc)
mem_data[0x1FF] = i;
PUSH(i);
break;
case 9: // LIBRARY STDLIB::CLS
puts("\033[2J");
fflush(stdout);
PUSH(0);
PUSH(0);
case 10: // LIBRARY STDLIB::GOTOXY
s = POP + 1;
i = POP + 1;
printf("\033[%d;%df", s, i);
fflush(stdout);
PUSH(0);
break;
case 11: // LIBRARY STDLIB::PUTNL
case 8: // LIBRARY STDLIB::PUTNL
putchar('\n');
fflush(stdout);
PUSH(0);
break;
default:
printf("Bad call code\n");
printf("\nBad call code:$%02X\n", mem_data[pc - 1]);
exit(1);
}
}
@ -880,22 +875,16 @@ void interp(code *ip)
}
char *stdlib_exp[] = {
"VIEWPORT",
"PUTC",
"PUTS",
"PUTSZ",
"GETC",
"GETS",
"CLS",
"GOTOXY",
"PUTNL",
"PUTLN",
"MACHID",
0
};
byte stdlib[] = {
0x00
};
int main(int argc, char **argv)
{
byte dci[32];

View File

@ -40,21 +40,19 @@ ALTWROFF= $C004
ALTWRON = $C005
!SOURCE "plvm02zp.inc"
STRBUF = $0280
;**********************************************************
;*
;* INTERPRETER INSTRUCTION POINTER INCREMENT MACRO
;*
;**********************************************************
!MACRO INC_IP {
INY
BNE * + 4
INC IPH
}
;***********************************************
;*
;* INTERPRETER INITIALIZATION
;*
;***********************************************
;******************************
;* *
;* INTERPRETER INITIALIZATION *
;* *
;******************************
* = $2000
LDX #$FF
TXS
@ -161,51 +159,9 @@ RAMDONE CLI
STA $D103,Y ; YEAH, I HARDCODED THE ADDRESS
DEY
BPL -
;*
;* LOOK FOR STARTUP FILE
;*
JSR PRODOS ; OPEN AUTORUN
!BYTE $C8
!WORD OPENPARMS
BNE NOAUTO
LDA REFNUM
STA NLPARMS+1
JSR PRODOS
!BYTE $C9
!WORD NLPARMS
BNE NOAUTO
LDA REFNUM
STA READPARMS+1
JSR PRODOS
!BYTE $CA
!WORD READPARMS
BNE NOAUTO
LDX READPARMS+6
STX STRBUF ; STRING LENGTH
JSR PRODOS
!BYTE $CC
!WORD CLOSEPARMS
NOAUTO JMP CMDEXEC
JMP CMDEXEC
GETPFXPARMS !BYTE 1
!WORD STRBUF ; PATH STRING GOES HERE
AUTORUN !BYTE 7
!TEXT "AUTORUN"
OPENPARMS !BYTE 3
!WORD AUTORUN
!WORD $0800
REFNUM !BYTE 0
NLPARMS !BYTE 3
!BYTE 0
!BYTE $7F
!BYTE $0D
READPARMS !BYTE 4
!BYTE 0
!WORD STRBUF+1
!WORD $0080
!WORD 0
CLOSEPARMS !BYTE 1
!BYTE 0
PAGE3 = *
!PSEUDOPC $03D0 {
;*
@ -220,6 +176,11 @@ INTERP BIT LCRDEN+LCBNK2 ; $03D0 - DIRECT INTERP ENTRY
TMRVEC !WORD TMRRTS
TMRRTS RTS
}
;************************************************
;* *
;* LANGUAGE CARD RESIDENT PLASMA VM STARTS HERE *
;* *
;************************************************
VMCORE = *
!PSEUDOPC $D000 {
;*
@ -245,12 +206,9 @@ OPTBL !WORD ZERO,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 00 02 04 06 08 0A 0C 0E
!WORD LB,LW,LLB,LLW,LAB,LAW,DLB,DLW ; 60 62 64 66 68 6A 6C 6E
!WORD SB,SW,SLB,SLW,SAB,SAW,DAB,DAW ; 70 72 74 76 78 7A 7C 7E
;*
;* 'BYE' COMMAND PROCESSING
;* 'BYE' PROCESSING - COPIED TO $1000 ON PRODOS BYE COMMAND
;*
!PSEUDOPC $1000 {
;*
;* CLEAR COMMAND LINE LENGTH BYTE IF CALLED FROM 'BYE'
;*
BYE JMP CPYCMD
DEFCMD !FILL 63 ; AT $D103 IN LC MEMORY
CPYCMD LDY DEFCMD
@ -258,31 +216,10 @@ CPYCMD LDY DEFCMD
STA STRBUF,Y
DEY
BPL -
;*
;* MOVE REST OF CMD FROM LANGUAGE CARD
;*
CMDEXEC LDY #$00
STY SRCL
STY DSTL
LDA #$D2
STA SRCH
LDA #$11
STA DSTH
BIT LCRDEN+LCBNK2
- LDA (SRC),Y
STA (DST),Y
INY
BNE -
INC SRCH
INC DSTH
LDA SRCH
CMP #$D4 ; #$E0
BNE -
;*
;* DEACTIVATE 80 COL CARDS
;*
LDX #$FE
TXS
CMDEXEC = *
;
; DEACTIVATE 80 COL CARDS
;
BIT ROMEN
LDY #4
- LDA DISABLE80,Y
@ -294,16 +231,56 @@ CMDEXEC LDY #$00
BIT $C051
BIT $C058
JSR $FC58 ; HOME
;*
;* JUMP TO INTERPRETER
;*
START LDA #$00
STA IFPL
LDA #$BF
STA IFPH
LDX #ESTKSZ/2
!SOURCE "cmdexec.a"
;
; READ CMD INTO MEMORY
;
JSR PRODOS ; CLOSE EVERYTHING
!BYTE $CC
!WORD CLOSEPARMS
BNE FAIL
JSR PRODOS ; OPEN CMD
!BYTE $C8
!WORD OPENPARMS
BNE FAIL
LDA REFNUM
STA READPARMS+1
JSR PRODOS
!BYTE $CA
!WORD READPARMS
BNE FAIL
JSR PRODOS
!BYTE $CC
!WORD CLOSEPARMS
BNE FAIL
JMP $2000 ; JUMP TO LOADED SYSTEM COMMAND
;
; PRINT FAIL MESSAGE, WAIT FOR KEYPRESS, AND REBOOT
;
FAIL INC $3F4 ; INVALIDATE POWER-UP BYTE
LDY #$01
- LDA FAILMSG,Y
ORA #$80
JSR $FDED
INY
CPY FAILMSG
BNE -
JSR $FD0C ; WAIT FOR KEYPRESS
JMP ($FFFC) ; RESET
OPENPARMS !BYTE 3
!WORD STRBUF
!WORD $0800
REFNUM !BYTE 0
READPARMS !BYTE 4
!BYTE 0
!WORD $2000
!WORD $1100
!WORD 0
CLOSEPARMS !BYTE 1
!BYTE 0
DISABLE80 !BYTE 21, 13, '1', 26, 13
FAILMSG !BYTE 39
!TEXT "MISSING CMD. PRESS ANY KEY TO RESET..."
ENDBYE = *
}
;*
;* ENTER INTO BYTECODE INTERPRETER
@ -359,12 +336,12 @@ NEXTOPX INY
FETCHOPX LDA (IP),Y
STA *+4
JMP (OPXTBL) ; USE AUX OPCODES
TIMERX STA ALTRDOFF
CLI
JSR JMPTMR
SEI
STA ALTRDON
JMP FETCHOPX
;TIMERX STA ALTRDOFF
; CLI
; JSR JMPTMR
; SEI
; STA ALTRDON
; JMP FETCHOPX
;*
;* INTERP BYTECODE IN MAIN MEM
;*
@ -379,8 +356,8 @@ FETCHOP LDA (IP),Y
ORA #$80 ; USE MAIN OPCODES
STA *+4
JMP (OPTBL)
TIMER JSR JMPTMR
JMP FETCHOP
;TIMER JSR JMPTMR
; JMP FETCHOP
;*
;* INDIRECT JUMP TO (TMRVEC)
;*

View File

@ -1,10 +1,11 @@
import stdlib
predef cls, gotoxy, viewport, putc, puts, getc, gets
predef putc, putln, puts, getc, gets
predef call, syscall
predef heapmark, heapallocallign, heapalloc, heaprelease, heapavail
predef memset, memcpy
predef isugt, isuge, isult, isule
predef load, exec
word MACHID, sysvars
;
; System flags: memory allocator screen holes.
;

View File

@ -9,7 +9,13 @@ include(testlib.plh)
; Declare all global variables for this module.
;
byte hello[] = "Hello, world.\n"
byte hello[] = "Hello, Apple "
byte a1[] = "1"
byte a2[] = "]["
byte a2p[] = "][+"
byte a2e[] = "//e"
byte a2c[] = "//c"
byte a3[] = "///"
word struct[] = 1, 10, 100, 1000, 10000
byte spaces[] = " "
@ -47,14 +53,28 @@ def nums(range)
end
export def main(range)
cls
nums(*range)
tens(*range*10)
viewport(12, 12, 16, 8)
ascii
viewport(0, 0, 40, 24)
gotoxy(15,5)
putln
puts(@hello)
when MACHID & $C8
is $08
puts(@a1)
is $00
puts(@a2)
is $40
puts(@a2p)
is $80
puts(@a2e)
is $88
puts(@a2c)
is $C0
puts(@a3)
otherwise
putc('?')
wend
putln
end
main(@struct:6)

View File

@ -38,10 +38,6 @@ export def puti(i)
fin
end
export def putln
putc($0D)
end
puts(@loadstr)
putln
done