mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-12-26 04:32:05 +00:00
Loading and running bytecode in AUX memory
This commit is contained in:
parent
a7db164fd4
commit
f9efda890f
@ -1,3 +1,4 @@
|
|||||||
|
const MACHID = $BF98
|
||||||
const iobuffer = $0800
|
const iobuffer = $0800
|
||||||
const databuff = $0C00
|
const databuff = $0C00
|
||||||
const MODADDR = $1000
|
const MODADDR = $1000
|
||||||
@ -29,10 +30,11 @@ byte version[] = "PLASMA VERSION 0.9"
|
|||||||
byte errorstr[] = "ERROR: $"
|
byte errorstr[] = "ERROR: $"
|
||||||
byte okstr[] = "OK"
|
byte okstr[] = "OK"
|
||||||
byte heaperr[] = "ERR: OUT OF HEAP\n"
|
byte heaperr[] = "ERR: OUT OF HEAP\n"
|
||||||
;byte xheaperr[] = "ERR: OUT OF AUX HEAP\n"
|
byte xheaperr[] = "ERR: OUT OF AUX HEAP\n"
|
||||||
byte heapstr[] = "HEAP START: $"
|
byte heapstr[] = "HEAP START: $"
|
||||||
byte freestr[] = "MEM FREE: $"
|
byte freestr[] = "MEM FREE: $"
|
||||||
byte prefix[32] = ""
|
byte prefix[32] = ""
|
||||||
|
byte adddefstr[] = "ADD DEF = "
|
||||||
;
|
;
|
||||||
; Standard Library exported functions.
|
; Standard Library exported functions.
|
||||||
;
|
;
|
||||||
@ -52,15 +54,15 @@ byte hpalignstr[] = "HEAPALLOCALIGN"
|
|||||||
byte hpallocstr[] = "HEAPALLOC"
|
byte hpallocstr[] = "HEAPALLOC"
|
||||||
byte hprelstr[] = "HEAPRELEASE"
|
byte hprelstr[] = "HEAPRELEASE"
|
||||||
byte hpavailstr[] = "HEAPAVAIL"
|
byte hpavailstr[] = "HEAPAVAIL"
|
||||||
;byte xhpmarkstr[] = "XHEAPMARK"
|
byte xhpmarkstr[] = "XHEAPMARK"
|
||||||
;byte xhpallocstr[]= "XHEAPALLOC"
|
byte xhpallocstr[]= "XHEAPALLOC"
|
||||||
;byte xhprelstr[] = "XHEAPRELEASE"
|
byte xhprelstr[] = "XHEAPRELEASE"
|
||||||
;byte xhpavailstr[]= "XHEAPAVAIL"
|
byte xhpavailstr[]= "XHEAPAVAIL"
|
||||||
byte memclrstr[] = "MEMCLR"
|
byte memclrstr[] = "MEMCLR"
|
||||||
byte memsetstr[] = "MEMSET"
|
byte memsetstr[] = "MEMSET"
|
||||||
byte memcpystr[] = "MEMCPY"
|
byte memcpystr[] = "MEMCPY"
|
||||||
;byte xmemcpystr[] = "XMEMCPY"
|
byte xmemcpystr[] = "XMEMCPY"
|
||||||
;byte memxcpystr[] = "MEMXCPY"
|
byte memxcpystr[] = "MEMXCPY"
|
||||||
byte uisgtstr[] = "ISUGT"
|
byte uisgtstr[] = "ISUGT"
|
||||||
byte uisgestr[] = "ISUGE"
|
byte uisgestr[] = "ISUGE"
|
||||||
byte uisltstr[] = "ISULT"
|
byte uisltstr[] = "ISULT"
|
||||||
@ -79,16 +81,16 @@ word = @hpmarkstr, @markheap
|
|||||||
word = @hpallocstr,@allocheap
|
word = @hpallocstr,@allocheap
|
||||||
word = @hpalignstr,@allocalignheap
|
word = @hpalignstr,@allocalignheap
|
||||||
word = @hprelstr, @releaseheap
|
word = @hprelstr, @releaseheap
|
||||||
;word = @xhpavailstr,@availxheap
|
word = @xhpavailstr,@availxheap
|
||||||
;word = @xhpmarkstr,@markxheap
|
word = @xhpmarkstr,@markxheap
|
||||||
;word = @xhpallocstr,@allocxheap
|
word = @xhpallocstr,@allocxheap
|
||||||
;word = @xhprelstr, @releasexheap
|
word = @xhprelstr, @releasexheap
|
||||||
;word = @xhpavailstr,@availxheap
|
word = @xhpavailstr,@availxheap
|
||||||
word = @memclrstr, @memclr
|
word = @memclrstr, @memclr
|
||||||
word = @memsetstr, @memset
|
word = @memsetstr, @memset
|
||||||
word = @memcpystr, @memcpy
|
word = @memcpystr, @memcpy
|
||||||
;word = @xmemcpystr,@xmemcpy
|
word = @xmemcpystr,@xmemcpy
|
||||||
;word = @memxcpystr,@memxcpy
|
word = @memxcpystr,@memxcpy
|
||||||
word = @uisgtstr, @uword_isgt
|
word = @uisgtstr, @uword_isgt
|
||||||
word = @uisgestr, @uword_isge
|
word = @uisgestr, @uword_isge
|
||||||
word = @uisltstr, @uword_islt
|
word = @uisltstr, @uword_islt
|
||||||
@ -97,8 +99,7 @@ word = 0
|
|||||||
;
|
;
|
||||||
; System variable.
|
; System variable.
|
||||||
;
|
;
|
||||||
word heapstart, heap
|
word heapstart, heap, xheap
|
||||||
;word xheap
|
|
||||||
word sysflags
|
word sysflags
|
||||||
word lastsym
|
word lastsym
|
||||||
word perr
|
word perr
|
||||||
@ -348,65 +349,61 @@ end
|
|||||||
;
|
;
|
||||||
; COPY FROM MAIN MEM TO AUX MEM.
|
; COPY FROM MAIN MEM TO AUX MEM.
|
||||||
;
|
;
|
||||||
; MEMXCPY(SRC, DST, SIZE)
|
; MEMXCPY(DST, SRC, SIZE)
|
||||||
;
|
;
|
||||||
;asm memxcpy
|
asm memxcpy
|
||||||
; LDA ESTKL+2,X
|
LDA ESTKL+1,X
|
||||||
; STA $3C
|
STA $3C
|
||||||
; LDA ESTKH+2,X
|
CLC
|
||||||
; STA $3D
|
ADC ESTKL,X
|
||||||
; LDA ESTKL+1,X
|
STA $3E
|
||||||
; STA $42
|
LDA ESTKH+1,X
|
||||||
; LDA ESTKH+1,X
|
STA $3D
|
||||||
; STA $43
|
ADC ESTKH,X
|
||||||
; LDA ESTKL,X
|
STA $3F
|
||||||
; CLC
|
LDA ESTKL+2,X
|
||||||
; ADC $3C
|
STA $42
|
||||||
; STA $3E
|
LDA ESTKH+2,X
|
||||||
; LDA ESTKH,X
|
STA $43
|
||||||
; ADC $3D
|
STX ESP
|
||||||
; STA $3F
|
BIT ROMEN
|
||||||
; STX ESP
|
SEC
|
||||||
; BIT ROMEN
|
JSR $C311
|
||||||
; SEC
|
BIT LCRDEN+LCBNK2
|
||||||
; JSR $C312
|
LDX ESP
|
||||||
; BIT LCRDEN+LCBNK2
|
INX
|
||||||
; LDX ESP
|
INX
|
||||||
; INX
|
RTS
|
||||||
; INX
|
end
|
||||||
; RTS
|
|
||||||
;end
|
|
||||||
;
|
;
|
||||||
; COPY FROM AUX MEM TO MAIN MEM.
|
; COPY FROM AUX MEM TO MAIN MEM.
|
||||||
;
|
;
|
||||||
; XMEMCPY(SRC, DST, SIZE)
|
; XMEMCPY(DST, SRC, SIZE)
|
||||||
;
|
;
|
||||||
;asm xmemcpy
|
asm xmemcpy
|
||||||
; LDA ESTKL+2,X
|
LDA ESTKL+1,X
|
||||||
; STA $3C
|
STA $3C
|
||||||
; LDA ESTKH+2,X
|
CLC
|
||||||
; STA $3D
|
ADC ESTKL,X
|
||||||
; LDA ESTKL+1,X
|
STA $3E
|
||||||
; STA $42
|
LDA ESTKH+1,X
|
||||||
; LDA ESTKH+1,X
|
STA $3D
|
||||||
; STA $43
|
ADC ESTKH,X
|
||||||
; LDA ESTKL,X
|
STA $3F
|
||||||
; CLC
|
LDA ESTKL+2,X
|
||||||
; ADC $3C
|
STA $42
|
||||||
; STA $3E
|
LDA ESTKH+2,X
|
||||||
; LDA ESTKH,X
|
STA $43
|
||||||
; ADC $3D
|
STX ESP
|
||||||
; STA $3F
|
BIT ROMEN
|
||||||
; STX ESP
|
CLC
|
||||||
; BIT ROMEN
|
JSR $C311
|
||||||
; CLC
|
BIT LCRDEN+LCBNK2
|
||||||
; JSR $C312
|
LDX ESP
|
||||||
; BIT LCRDEN+LCBNK2
|
INX
|
||||||
; LDX ESP
|
INX
|
||||||
; INX
|
RTS
|
||||||
; INX
|
end
|
||||||
; RTS
|
|
||||||
;end
|
|
||||||
;
|
;
|
||||||
; HOME
|
; HOME
|
||||||
;
|
;
|
||||||
@ -792,54 +789,54 @@ def releaseheap(newheap)
|
|||||||
heap = newheap;
|
heap = newheap;
|
||||||
return @newheap - heap;
|
return @newheap - heap;
|
||||||
end
|
end
|
||||||
;def availxheap(void)
|
def availxheap(void)
|
||||||
; return $BF00 - xheap;
|
return $BF00 - xheap;
|
||||||
;end
|
end
|
||||||
;def allocxheap(size)
|
def allocxheap(size)
|
||||||
; word addr
|
word xaddr
|
||||||
; addr = heap
|
xaddr = xheap
|
||||||
; xheap = xheap + size
|
xheap = xheap + size
|
||||||
; if sysflags & restxt1
|
if sysflags & restxt1
|
||||||
; if uword_isle(addr, $0800) and uword_isgt(xheap, $0400)
|
if uword_isle(xaddr, $0800) and uword_isgt(xheap, $0400)
|
||||||
; addr = $4000
|
xaddr = $4000
|
||||||
; xheap = addr + size
|
xheap = xaddr + size
|
||||||
; fin
|
fin
|
||||||
; fin
|
fin
|
||||||
; if sysflags & restxt2
|
if sysflags & restxt2
|
||||||
; if uword_isle(addr, $0C00) and uword_isgt(xheap, $0800)
|
if uword_isle(xaddr, $0C00) and uword_isgt(xheap, $0800)
|
||||||
; addr = $4000
|
xaddr = $4000
|
||||||
; xheap = addr + size
|
xheap = xaddr + size
|
||||||
; fin
|
fin
|
||||||
; fin
|
fin
|
||||||
; if sysflags & resxhgr1
|
if sysflags & resxhgr1
|
||||||
; if uword_isle(addr, $4000) and uword_isgt(xheap, $2000)
|
if uword_isle(xaddr, $4000) and uword_isgt(xheap, $2000)
|
||||||
; addr = $4000
|
xaddr = $4000
|
||||||
; xheap = addr + size
|
xheap = xaddr + size
|
||||||
; fin
|
fin
|
||||||
; fin
|
fin
|
||||||
; if sysflags & resxhgr2
|
if sysflags & resxhgr2
|
||||||
; if uword_isle(addr, $6000) and uword_isgt(xheap, $4000)
|
if uword_isle(xaddr, $6000) and uword_isgt(xheap, $4000)
|
||||||
; addr = $6000
|
xaddr = $6000
|
||||||
; xheap = addr + size
|
xheap = xaddr + size
|
||||||
; fin
|
fin
|
||||||
; fin
|
fin
|
||||||
; if uword_isge(xheap, $BF00)
|
if uword_isge(xheap, $BF00)
|
||||||
; prstr(@xheaperr)
|
prstr(@xheaperr)
|
||||||
; return 0
|
return 0
|
||||||
; fin
|
fin
|
||||||
; return addr
|
return xaddr
|
||||||
;end
|
end
|
||||||
;def freexheap(size)
|
def freexheap(size)
|
||||||
; xheap = xheap - size
|
xheap = xheap - size
|
||||||
; return $BF00 - heap
|
return $BF00 - heap
|
||||||
;end
|
end
|
||||||
;def markxheap
|
def markxheap
|
||||||
; return xheap
|
return xheap
|
||||||
;end
|
end
|
||||||
;def releasexheap(newxheap)
|
def releasexheap(newxheap)
|
||||||
; xheap = newxheap;
|
xheap = newxheap;
|
||||||
; return $BF00 - xheap
|
return $BF00 - xheap
|
||||||
;end
|
end
|
||||||
;
|
;
|
||||||
; DCI table routines,
|
; DCI table routines,
|
||||||
;
|
;
|
||||||
@ -939,6 +936,13 @@ def addmod(mod, addr)
|
|||||||
return addtbl(modtosym(mod, @dci), addr, @lastsym)
|
return addtbl(modtosym(mod, @dci), addr, @lastsym)
|
||||||
end
|
end
|
||||||
def adddef(bank, addr, deflast)
|
def adddef(bank, addr, deflast)
|
||||||
|
prstr(@adddefstr)
|
||||||
|
prbyte(bank)
|
||||||
|
cout(':')
|
||||||
|
prword(addr)
|
||||||
|
cout('@')
|
||||||
|
prword(*deflast)
|
||||||
|
crout
|
||||||
(*deflast).0 = $20
|
(*deflast).0 = $20
|
||||||
if bank == 0
|
if bank == 0
|
||||||
(*deflast):1 = $03D6 ; JSR $03D6 (MAIN MEM INTERP)
|
(*deflast):1 = $03D6 ; JSR $03D6 (MAIN MEM INTERP)
|
||||||
@ -973,11 +977,11 @@ def lookupextern(esd, index)
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
def loadmod(mod)
|
def loadmod(mod)
|
||||||
word refnum, len, modsize, flags, bytecode, defcnt, fixup, addr, init, modaddr, modfix
|
word refnum, rdlen, modsize, flags, bytecode, defofst, defcnt, init, fixup
|
||||||
|
word addr, defaddr, modaddr, modfix
|
||||||
word deftbl, deflast
|
word deftbl, deflast
|
||||||
word moddep, rld, esd, cdd, sym;
|
word moddep, rld, esd, cdd, sym;
|
||||||
byte str[16]
|
byte defbank, str[16], filename[64]
|
||||||
byte filename[64]
|
|
||||||
byte header[128]
|
byte header[128]
|
||||||
|
|
||||||
;
|
;
|
||||||
@ -987,15 +991,15 @@ def loadmod(mod)
|
|||||||
refnum = open(@filename, iobuffer)
|
refnum = open(@filename, iobuffer)
|
||||||
if refnum > 0
|
if refnum > 0
|
||||||
init = 0
|
init = 0
|
||||||
len = read(refnum, @header, 128)
|
rdlen = read(refnum, @header, 128)
|
||||||
modsize = header:0
|
modsize = header:0
|
||||||
if len > 4 and header:2 == $DA7E ; DAVE = magic number :-)
|
if rdlen > 4 and header:2 == $DA7E ; DAVE = magic number :-)
|
||||||
;
|
;
|
||||||
; This is an EXTended RELocatable (data+bytecode) module.
|
; This is an EXTended RELocatable (data+bytecode) module.
|
||||||
;
|
;
|
||||||
flags = header:4
|
flags = header:4
|
||||||
sysflags = sysflags | flags
|
sysflags = sysflags | flags
|
||||||
bytecode = header:6
|
defofst = header:6
|
||||||
defcnt = header:8
|
defcnt = header:8
|
||||||
init = header:10
|
init = header:10
|
||||||
moddep = @header + 12
|
moddep = @header + 12
|
||||||
@ -1025,37 +1029,46 @@ def loadmod(mod)
|
|||||||
; Reset read pointer.
|
; Reset read pointer.
|
||||||
;
|
;
|
||||||
refnum = open(@filename, iobuffer)
|
refnum = open(@filename, iobuffer)
|
||||||
len = read(refnum, @header, 128)
|
rdlen = read(refnum, @header, 128)
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
;
|
;
|
||||||
; Alloc heap space for relocated module (data + bytecode).
|
; Alloc heap space for relocated module (data + bytecode).
|
||||||
;
|
;
|
||||||
modaddr = allocheap(modsize)
|
modaddr = allocheap(modsize)
|
||||||
memcpy(modaddr, @header, len)
|
memcpy(modaddr, @header, rdlen)
|
||||||
;
|
;
|
||||||
; Raad in remainder of module into memory for fixups.
|
; Read in remainder of module into memory for fixups.
|
||||||
;
|
;
|
||||||
addr = modaddr + len;
|
addr = modaddr;
|
||||||
repeat
|
repeat
|
||||||
len = read(refnum, addr, 4096)
|
addr = addr + rdlen
|
||||||
addr = addr + len
|
rdlen = read(refnum, addr, 4096)
|
||||||
until len <= 0
|
until rdlen <= 0
|
||||||
close(refnum)
|
close(refnum)
|
||||||
;
|
;
|
||||||
; Apply all fixups and symbol import/export.
|
; Apply all fixups and symbol import/export.
|
||||||
;
|
;
|
||||||
len = *modaddr
|
|
||||||
modfix = modaddr - MODADDR
|
modfix = modaddr - MODADDR
|
||||||
bytecode = bytecode + modfix
|
bytecode = defofst + modfix
|
||||||
rld = modaddr + len ; Re-Locatable Directory
|
rld = modaddr + modsize ; Re-Locatable Directory
|
||||||
cdd = rld ; Code Definition Directory
|
cdd = rld ; Code Definition Directory
|
||||||
esd = rld ; Extern+Entry Symbol Directory
|
esd = rld ; Extern+Entry Symbol Directory
|
||||||
while ^esd <> $00 ; Scan to end of RLD
|
while ^esd <> $00 ; Scan to end of ESD
|
||||||
esd = esd + 4
|
esd = esd + 4
|
||||||
loop
|
loop
|
||||||
esd = esd + 1
|
esd = esd + 1
|
||||||
;
|
;
|
||||||
|
; Locate bytecode defs in appropriate bank.
|
||||||
|
;
|
||||||
|
if ^MACHID & $30
|
||||||
|
defbank = 1
|
||||||
|
defaddr = allocxheap(rld - bytecode)
|
||||||
|
else
|
||||||
|
defbank = 0
|
||||||
|
defaddr = bytecode
|
||||||
|
fin
|
||||||
|
;
|
||||||
; Run through the Re-Location Dictionary.
|
; Run through the Re-Location Dictionary.
|
||||||
;
|
;
|
||||||
while ^rld
|
while ^rld
|
||||||
@ -1063,9 +1076,9 @@ def loadmod(mod)
|
|||||||
;
|
;
|
||||||
; This is a bytcode def entry - add it to the def directory.
|
; This is a bytcode def entry - add it to the def directory.
|
||||||
;
|
;
|
||||||
addr = (rld):1 + modfix
|
;addr = (rld):1 + modfix
|
||||||
(rld):1 = addr
|
;(rld):1 = addr
|
||||||
adddef(0, addr, @deflast)
|
adddef(defbank, (rld):1 - defofst + defaddr, @deflast)
|
||||||
else
|
else
|
||||||
addr = (rld):1 + modfix
|
addr = (rld):1 + modfix
|
||||||
if ^rld & $80
|
if ^rld & $80
|
||||||
@ -1087,7 +1100,7 @@ def loadmod(mod)
|
|||||||
;
|
;
|
||||||
; Bytecode address - replace with call def directory.
|
; Bytecode address - replace with call def directory.
|
||||||
;
|
;
|
||||||
fixup = lookupdef(fixup, deftbl)
|
fixup = lookupdef(fixup - bytecode + defaddr, deftbl)
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
if ^rld & $80
|
if ^rld & $80
|
||||||
@ -1124,12 +1137,22 @@ def loadmod(mod)
|
|||||||
;
|
;
|
||||||
; Use the def directory address for bytecode.
|
; Use the def directory address for bytecode.
|
||||||
;
|
;
|
||||||
addr = lookupdef(0, addr, deftbl)
|
addr = lookupdef(0, addr - bytecode + defaddr, deftbl)
|
||||||
fin
|
fin
|
||||||
addsym(sym, addr)
|
addsym(sym, addr)
|
||||||
fin
|
fin
|
||||||
esd = esd + 3
|
esd = esd + 3
|
||||||
loop
|
loop
|
||||||
|
if defbank
|
||||||
|
;
|
||||||
|
; Move bytecode to AUX bank.
|
||||||
|
;
|
||||||
|
memxcpy(defaddr, bytecode, modsize - (bytecode - modaddr))
|
||||||
|
;
|
||||||
|
; Free up the bytecode in main memory.
|
||||||
|
;
|
||||||
|
releaseheap(bytecode)
|
||||||
|
fin
|
||||||
else
|
else
|
||||||
perr = perr | 0x100
|
perr = perr | 0x100
|
||||||
return -perr
|
return -perr
|
||||||
@ -1138,86 +1161,89 @@ def loadmod(mod)
|
|||||||
; Call init routine if it exists.
|
; Call init routine if it exists.
|
||||||
;
|
;
|
||||||
if init
|
if init
|
||||||
return adddef(0, init + modfix, @deflast)()
|
return adddef(defbank, init - defofst + defaddr, @deflast)()
|
||||||
fin
|
fin
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
;
|
;
|
||||||
; Command mode
|
; Command mode
|
||||||
;
|
;
|
||||||
def volumes
|
;def volumes
|
||||||
word strbuf
|
; word strbuf
|
||||||
byte i
|
; byte i
|
||||||
|
|
||||||
strbuf = online()
|
; strbuf = online()
|
||||||
for i = 0 to 15
|
; for i = 0 to 15
|
||||||
^strbuf = ^strbuf & $0F
|
; ^strbuf = ^strbuf & $0F
|
||||||
if ^strbuf
|
; if ^strbuf
|
||||||
cout('/')
|
; cout('/')
|
||||||
prstr(strbuf)
|
; prstr(strbuf)
|
||||||
crout()
|
; crout()
|
||||||
fin
|
; fin
|
||||||
strbuf = strbuf + 16
|
; strbuf = strbuf + 16
|
||||||
next
|
; next
|
||||||
end
|
;end
|
||||||
def catalog(optpath)
|
;def catalog(optpath)
|
||||||
byte path[64]
|
; byte path[64]
|
||||||
byte refnum
|
; byte refnum
|
||||||
byte firstblk
|
; byte firstblk
|
||||||
byte entrylen, entriesblk
|
; byte entrylen, entriesblk
|
||||||
byte i, type, len
|
; byte i, type, len
|
||||||
word entry, filecnt
|
; word entry, filecnt
|
||||||
|
|
||||||
if ^optpath
|
; if ^optpath
|
||||||
memcpy(@path, optpath, ^optpath + 1)
|
; memcpy(@path, optpath, ^optpath + 1)
|
||||||
else
|
; else
|
||||||
getpfx(@path)
|
; getpfx(@path)
|
||||||
prstr(@path)
|
; prstr(@path)
|
||||||
crout()
|
; crout()
|
||||||
fin
|
; fin
|
||||||
refnum = open(@path, iobuffer)
|
; refnum = open(@path, iobuffer)
|
||||||
if perr
|
; if perr
|
||||||
return perr
|
; return perr
|
||||||
fin
|
; fin
|
||||||
firstblk = 1
|
; firstblk = 1
|
||||||
repeat
|
; repeat
|
||||||
if read(refnum, databuff, 512) == 512
|
; if read(refnum, databuff, 512) == 512
|
||||||
entry = databuff + 4
|
; entry = databuff + 4
|
||||||
if firstblk
|
; if firstblk
|
||||||
entrylen = databuff.$23
|
; entrylen = databuff.$23
|
||||||
entriesblk = databuff.$24
|
; entriesblk = databuff.$24
|
||||||
filecnt = databuff:$25
|
; filecnt = databuff:$25
|
||||||
entry = entry + entrylen
|
; entry = entry + entrylen
|
||||||
fin
|
; fin
|
||||||
for i = firstblk to entriesblk
|
; for i = firstblk to entriesblk
|
||||||
type = ^entry
|
; type = ^entry
|
||||||
if type <> 0
|
; if type <> 0
|
||||||
len = type & $0F
|
; len = type & $0F
|
||||||
^entry = len
|
; ^entry = len
|
||||||
prstr(entry)
|
; prstr(entry)
|
||||||
if type & $F0 == $D0 ; Is it a directory?
|
; if type & $F0 == $D0 ; Is it a directory?
|
||||||
cout('/')
|
; cout('/')
|
||||||
len = len + 1
|
; len = len + 1
|
||||||
elsif (entry).$10 == $FF
|
; elsif (entry).$10 == $FF
|
||||||
cout('*')
|
; cout('-')
|
||||||
len = len + 1
|
; len = len + 1
|
||||||
fin
|
; elsif (entry).$10 == $FE
|
||||||
for len = 19 - len downto 0
|
; cout('+')
|
||||||
cout(' ')
|
; len = len + 1
|
||||||
next
|
; fin
|
||||||
filecnt = filecnt - 1
|
; for len = 19 - len downto 0
|
||||||
fin
|
; cout(' ')
|
||||||
entry = entry + entrylen
|
; next
|
||||||
next
|
; filecnt = filecnt - 1
|
||||||
firstblk = 0
|
; fin
|
||||||
else
|
; entry = entry + entrylen
|
||||||
filecnt = 0
|
; next
|
||||||
fin
|
; firstblk = 0
|
||||||
until filecnt == 0
|
; else
|
||||||
close(refnum)
|
; filecnt = 0
|
||||||
crout()
|
; fin
|
||||||
return 0
|
; until filecnt == 0
|
||||||
end
|
; close(refnum)
|
||||||
|
; crout()
|
||||||
|
; return 0
|
||||||
|
;end
|
||||||
def stripchars(strptr)
|
def stripchars(strptr)
|
||||||
while ^strptr and ^(strptr + 1) <> ' '
|
while ^strptr and ^(strptr + 1) <> ' '
|
||||||
memcpy(strptr + 1, strptr + 2, ^strptr)
|
memcpy(strptr + 1, strptr + 2, ^strptr)
|
||||||
@ -1270,31 +1296,31 @@ def resetmemfiles
|
|||||||
^$BF58 = $CF
|
^$BF58 = $CF
|
||||||
^$BF6F = $01
|
^$BF6F = $01
|
||||||
end
|
end
|
||||||
def execsys(sysfile)
|
;def execsys(sysfile)
|
||||||
byte refnum
|
; byte refnum
|
||||||
word len
|
; word len
|
||||||
|
|
||||||
if ^sysfile
|
; if ^sysfile
|
||||||
memcpy($280, sysfile, ^sysfile + 1)
|
; memcpy($280, sysfile, ^sysfile + 1)
|
||||||
striptrail(sysfile)
|
; striptrail(sysfile)
|
||||||
refnum = open(sysfile, iobuffer)
|
; refnum = open(sysfile, iobuffer)
|
||||||
if refnum
|
; if refnum
|
||||||
len = read(refnum, $2000, $FFFF)
|
; len = read(refnum, $2000, $FFFF)
|
||||||
resetmemfiles()
|
; resetmemfiles()
|
||||||
if len
|
; if len
|
||||||
memcpy(sysfile, $280, ^$280 + 1)
|
; memcpy(sysfile, $280, ^$280 + 1)
|
||||||
if stripchars(sysfile) and ^$2000 == $4C and *$2003 == $EEEE
|
; if stripchars(sysfile) and ^$2000 == $4C and *$2003 == $EEEE
|
||||||
stripspaces(sysfile)
|
; stripspaces(sysfile)
|
||||||
if ^$2006 <= ^sysfile
|
; if ^$2006 <= ^sysfile
|
||||||
memcpy($2006, sysfile, ^sysfile + 1)
|
; memcpy($2006, sysfile, ^sysfile + 1)
|
||||||
fin
|
; fin
|
||||||
fin
|
; fin
|
||||||
striptrail($280)
|
; striptrail($280)
|
||||||
exec()
|
; exec()
|
||||||
fin
|
; fin
|
||||||
fin
|
; fin
|
||||||
fin
|
; fin
|
||||||
end
|
;end
|
||||||
def execmod(modfile)
|
def execmod(modfile)
|
||||||
byte dci[17], moddci[17]
|
byte dci[17], moddci[17]
|
||||||
word saveheap, globals
|
word saveheap, globals
|
||||||
@ -1313,7 +1339,7 @@ def execmod(modfile)
|
|||||||
loop
|
loop
|
||||||
sysflags = 0
|
sysflags = 0
|
||||||
heap = heapstart
|
heap = heapstart
|
||||||
; xheap = $0400
|
xheap = $0400
|
||||||
loadmod(@moddci)
|
loadmod(@moddci)
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
@ -1335,15 +1361,15 @@ while 1
|
|||||||
when toupper(parsecmd(cmdptr))
|
when toupper(parsecmd(cmdptr))
|
||||||
is 'Q'
|
is 'Q'
|
||||||
reboot()
|
reboot()
|
||||||
is 'C'
|
; is 'C'
|
||||||
catalog(cmdptr)
|
; catalog(cmdptr)
|
||||||
is 'P'
|
is 'P'
|
||||||
setpfx(cmdptr)
|
setpfx(cmdptr)
|
||||||
is 'V'
|
; is 'V'
|
||||||
volumes();
|
; volumes();
|
||||||
is '-'
|
; is '-'
|
||||||
execsys(cmdptr)
|
; execsys(cmdptr)
|
||||||
perr = $46
|
; perr = $46
|
||||||
is '+'
|
is '+'
|
||||||
execmod(cmdptr)
|
execmod(cmdptr)
|
||||||
wend
|
wend
|
||||||
|
@ -152,17 +152,6 @@ PAGE3 = *
|
|||||||
VMCORE = *
|
VMCORE = *
|
||||||
!PSEUDOPC $D000 {
|
!PSEUDOPC $D000 {
|
||||||
;*
|
;*
|
||||||
;* OPCODE TABLE
|
|
||||||
;*
|
|
||||||
OPTBL !WORD ZERO,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 00 02 04 06 08 0A 0C 0E
|
|
||||||
!WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 10 12 14 16 18 1A 1C 1E
|
|
||||||
!WORD LNOT,LOR,LAND,LA,LLA,CB,CW,SWAP ; 20 22 24 26 28 2A 2C 2E
|
|
||||||
!WORD DROP,DUP,PUSH,PULL,BRGT,BRLT,BREQ,BRNE ; 30 32 34 36 38 3A 3C 3E
|
|
||||||
!WORD ISEQ,ISNE,ISGT,ISLT,ISGE,ISLE,BRFLS,BRTRU ; 40 42 44 46 48 4A 4C 4E
|
|
||||||
!WORD BRNCH,IBRNCH,CALL,ICAL,ENTER,LEAVE,RET,NEXTOP ; 50 52 54 56 58 5A 5C 5E
|
|
||||||
!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
|
|
||||||
;*
|
|
||||||
;* OPXCODE TABLE
|
;* OPXCODE TABLE
|
||||||
;*
|
;*
|
||||||
OPXTBL !WORD ZEROX,ADDX,SUBX,MULX,DIVX,MODX,INCRX,DECRX ; 00 02 04 06 08 0A 0C 0E
|
OPXTBL !WORD ZEROX,ADDX,SUBX,MULX,DIVX,MODX,INCRX,DECRX ; 00 02 04 06 08 0A 0C 0E
|
||||||
@ -174,6 +163,17 @@ OPXTBL !WORD ZEROX,ADDX,SUBX,MULX,DIVX,MODX,INCRX,DECRX ; 00 02 04 06 08 0
|
|||||||
!WORD LBX,LWX,LLBX,LLWX,LABX,LAWX,DLBX,DLWX ; 60 62 64 66 68 6A 6C 6E
|
!WORD LBX,LWX,LLBX,LLWX,LABX,LAWX,DLBX,DLWX ; 60 62 64 66 68 6A 6C 6E
|
||||||
!WORD SBX,SWX,SLBX,SLWX,SABX,SAWX,DABX,DAWX ; 70 72 74 76 78 7A 7C 7E
|
!WORD SBX,SWX,SLBX,SLWX,SABX,SAWX,DABX,DAWX ; 70 72 74 76 78 7A 7C 7E
|
||||||
;*
|
;*
|
||||||
|
;* OPCODE TABLE
|
||||||
|
;*
|
||||||
|
OPTBL !WORD ZERO,ADD,SUB,MUL,DIV,MOD,INCR,DECR ; 00 02 04 06 08 0A 0C 0E
|
||||||
|
!WORD NEG,COMP,BAND,IOR,XOR,SHL,SHR,IDXW ; 10 12 14 16 18 1A 1C 1E
|
||||||
|
!WORD LNOT,LOR,LAND,LA,LLA,CB,CW,SWAP ; 20 22 24 26 28 2A 2C 2E
|
||||||
|
!WORD DROP,DUP,PUSH,PULL,BRGT,BRLT,BREQ,BRNE ; 30 32 34 36 38 3A 3C 3E
|
||||||
|
!WORD ISEQ,ISNE,ISGT,ISLT,ISGE,ISLE,BRFLS,BRTRU ; 40 42 44 46 48 4A 4C 4E
|
||||||
|
!WORD BRNCH,IBRNCH,CALL,ICAL,ENTER,LEAVE,RET,NEXTOP ; 50 52 54 56 58 5A 5C 5E
|
||||||
|
!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' COMMAND PROCESSING
|
||||||
;*
|
;*
|
||||||
!PSEUDOPC $1000 {
|
!PSEUDOPC $1000 {
|
||||||
@ -274,6 +274,19 @@ IINTRPX STA LCRWEN+LCBNK2 ; WRITE ENABLE LANGUAGE CARD
|
|||||||
DEY
|
DEY
|
||||||
BEQ FETCHOPX
|
BEQ FETCHOPX
|
||||||
;*
|
;*
|
||||||
|
;* INTERP BYTECODE IN AUX MEM
|
||||||
|
;*
|
||||||
|
NEXTOPHX INC IPH
|
||||||
|
BNE FETCHOPX
|
||||||
|
DROPX INX
|
||||||
|
NEXTOPX INY
|
||||||
|
BEQ NEXTOPHX
|
||||||
|
FETCHOPX ;SEI
|
||||||
|
STA ALTRDON
|
||||||
|
LDA (IP),Y
|
||||||
|
STA *+4
|
||||||
|
JMP (OPXTBL)
|
||||||
|
;*
|
||||||
;* INTERP BYTECODE IN MAIN MEM
|
;* INTERP BYTECODE IN MAIN MEM
|
||||||
;*
|
;*
|
||||||
NEXTOPH INC IPH
|
NEXTOPH INC IPH
|
||||||
@ -282,23 +295,10 @@ DROP INX
|
|||||||
NEXTOP INY
|
NEXTOP INY
|
||||||
BEQ NEXTOPH
|
BEQ NEXTOPH
|
||||||
FETCHOP LDA (IP),Y
|
FETCHOP LDA (IP),Y
|
||||||
|
ORA #$80 ; SELECT OP OPCODES
|
||||||
STA *+4
|
STA *+4
|
||||||
JMP (OPTBL)
|
JMP (OPTBL)
|
||||||
;*
|
;*
|
||||||
;* INTERP BYTECODE IN AUX MEM
|
|
||||||
;*
|
|
||||||
NEXTOPHX INC IPH
|
|
||||||
BNE FETCHOPX
|
|
||||||
DROPX INX
|
|
||||||
NEXTOPX INY
|
|
||||||
BEQ NEXTOPHX
|
|
||||||
FETCHOPX SEI
|
|
||||||
STA ALTRDON
|
|
||||||
LDA (IP),Y
|
|
||||||
ORA #$80 ; SELECT OPX OPCODES
|
|
||||||
STA *+4
|
|
||||||
JMP (OPXTBL)
|
|
||||||
;*
|
|
||||||
;* INDIRECT JUMP TO (TMP)
|
;* INDIRECT JUMP TO (TMP)
|
||||||
;*
|
;*
|
||||||
JMPTMP JMP (TMP)
|
JMPTMP JMP (TMP)
|
||||||
@ -1030,7 +1030,7 @@ LLBX +INC_IP
|
|||||||
LDA #$00
|
LDA #$00
|
||||||
STA ESTKH,X
|
STA ESTKH,X
|
||||||
LDY IPY
|
LDY IPY
|
||||||
JMP NEXTOP
|
JMP NEXTOPX
|
||||||
LLWX +INC_IP
|
LLWX +INC_IP
|
||||||
LDA (IP),Y
|
LDA (IP),Y
|
||||||
STY IPY
|
STY IPY
|
||||||
@ -1043,7 +1043,7 @@ LLWX +INC_IP
|
|||||||
LDA (IFP),Y
|
LDA (IFP),Y
|
||||||
STA ESTKH,X
|
STA ESTKH,X
|
||||||
LDY IPY
|
LDY IPY
|
||||||
JMP NEXTOP
|
JMP NEXTOPX
|
||||||
;*
|
;*
|
||||||
;* LOAD VALUE FROM ABSOLUTE ADDRESS
|
;* LOAD VALUE FROM ABSOLUTE ADDRESS
|
||||||
;*
|
;*
|
||||||
@ -1753,7 +1753,7 @@ CALLX +INC_IP
|
|||||||
PHA
|
PHA
|
||||||
TYA
|
TYA
|
||||||
PHA
|
PHA
|
||||||
CLI
|
;CLI
|
||||||
JSR JMPTMP
|
JSR JMPTMP
|
||||||
PLA
|
PLA
|
||||||
TAY
|
TAY
|
||||||
@ -1801,7 +1801,7 @@ ICALX LDA ESTKL,X
|
|||||||
TYA
|
TYA
|
||||||
PHA
|
PHA
|
||||||
STA ALTRDOFF
|
STA ALTRDOFF
|
||||||
CLI
|
;CLI
|
||||||
JSR JMPTMP
|
JSR JMPTMP
|
||||||
PLA
|
PLA
|
||||||
TAY
|
TAY
|
||||||
@ -1861,7 +1861,6 @@ ENTERX +INC_IP
|
|||||||
LDA (IP),Y
|
LDA (IP),Y
|
||||||
STA NPARMS
|
STA NPARMS
|
||||||
STY IPY
|
STY IPY
|
||||||
STA ALTRDOFF
|
|
||||||
LDA IFPL
|
LDA IFPL
|
||||||
PHA
|
PHA
|
||||||
SEC
|
SEC
|
||||||
@ -1871,6 +1870,7 @@ ENTERX +INC_IP
|
|||||||
PHA
|
PHA
|
||||||
SBC #$00
|
SBC #$00
|
||||||
STA IFPH
|
STA IFPH
|
||||||
|
STA ALTRDOFF
|
||||||
LDY #$01
|
LDY #$01
|
||||||
PLA
|
PLA
|
||||||
STA (IFP),Y
|
STA (IFP),Y
|
||||||
@ -1915,10 +1915,10 @@ LEAVEX STA ALTRDOFF
|
|||||||
STA IFPL
|
STA IFPL
|
||||||
PLA
|
PLA
|
||||||
STA IFPH
|
STA IFPH
|
||||||
CLI
|
;CLI
|
||||||
RTS
|
RTS
|
||||||
RETX STA ALTRDOFF
|
RETX STA ALTRDOFF
|
||||||
CLI
|
;CLI
|
||||||
RTS
|
RTS
|
||||||
VMEND = *
|
VMEND = *
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user