1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2024-07-05 04:28:57 +00:00

memory manager tester and more parse_value fixes

This commit is contained in:
David Schmenk 2015-01-22 16:57:32 -08:00
parent 8ff8a37a68
commit 06a7f9d0e3
6 changed files with 371 additions and 161 deletions

14
src/inc/memmgr.plh Normal file
View File

@ -0,0 +1,14 @@
import memmgr
//
// Utility routine
//
predef sweep, brk, sbrk
//
// Memory routines
//
predef hmemNew, hmemLock, hmemUnlock, hmemRef, hmemDel, hmemAvail, hmemLargestAvail
//
// Max size of a memory block
//
const MAX_MEMBLK_SIZE = $2000
end

View File

@ -1,7 +1,7 @@
//
// Handle based memory manager
// Handle based swapping memory manager
//
import STDLIB
import stdlib
predef syscall, call, memset, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
@ -23,7 +23,7 @@ struc t_initdata
byte entrylen
byte entriesblk
byte swapstrlen
byte[] info
byte[] volinfo
byte[] catalog
end
word initdata
@ -38,7 +38,7 @@ end
// Alloced memory block structure
//
struc t_memblk
byte blksiz
word blksiz
byte blkref
byte blklok
end
@ -53,19 +53,21 @@ end
//
// Block size
//
const MAX_BLK_SIZE = $0FE0
const MAX_BLK_MASK = $0FF0
const MIN_BLK_SIZE = $10
const MIN_BLK_MASK = $0F
const MAX_BLK_SIZE = $2010
const MAX_BLK_MASK = $1FFF
const MIN_BLK_SIZE = $08
const MIN_BLK_MASK = $07
//
// Block states
//
const HMEM_ADDR = $FFFC
const HMEM_STATE = $03
const HMEM_ADDR = $FFF8
const HMEM_SIZE = $FFF8
const HMEM_STATE = $07
const HMEM_MOVEABLE = $00 // Many dependencies on this being $00
const HMEM_AVAIL = $01
const HMEM_LOCKED = $02
const HMEM_SWAPPED = $03
const HMEM_UNINIT = $04
//
// Block flags
//
@ -89,11 +91,37 @@ byte[64] swapvol = "/" // Swap volume
byte swapdir = "/SWAP/"
byte hexchar = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
//
// DEBUG
//
//byte swapinstr = "Swap in:"
//byte swapoutstr = "Swap out:"
//byte getblkstr = "Get block = "
//byte allocpgstr = "Alloc page:"
//def putln
// return putc($0D)
//end
//def putb(hexb)
// return call($FDDA, hexb, 0, 0, 0)
//end
//def puth(hex)
// return call($F941, hex >> 8, hex, 0, 0)
//end
//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
//
// Fill block filename
//
def strcharadd(str, char)
^str = ^str + 1
str->[^str] = char
str->.[^str] = char
end
def swapfile(filestr, hmem)
memcpy(filestr, @swapvol, swapvol + 1)
@ -142,16 +170,6 @@ def write(refnum, buff, len)
syscall($CB, @params)
return params:6
end
def get_eof(refnum)
byte params[5]
params.0 = 2
params.1 = refnum
params:2 = 0
params.4 = 0
syscall($D1, @params)
return params:2
end
def get_info(path, infoptr)
byte params[18]
@ -242,7 +260,7 @@ end
def addfre(freblk)
word srch
freblk=>fresiz = freblk=>blksiz << 4
//freblk=>fresiz = freblk=>blksiz
if frelst and frelst < freblk
srch = frelst
while srch=>frenxt
@ -254,6 +272,7 @@ def addfre(freblk)
freblk=>frenxt = srch=>frenxt
srch=>frenxt=>freprv = freblk
srch=>frenxt = freblk
return
fin
srch = srch=>frenxt
loop
@ -268,32 +287,13 @@ def addfre(freblk)
// Add to beginning of list
//
freblk=>freprv = 0
freblk=>frenxt = frelst
frelst = freblk
freblk=>frenxt = frelst
if frelst
frelst=>freprv = freblk
fin
frelst = freblk
fin
end
def findexact(size)
word srch
srch = frelst
while srch
if srch=>fresiz == size
return unlink(srch)
fin
srch = srch=>frenxt
loop
end
def findbest(size)
word srch, shrink
srch = frelst
while srch
if srch=>fresiz >= size
return unfre(srch, size)
fin
srch = srch=>frenxt
loop
end
//
// Memory coallesce/compaction/swap out routines
//
@ -302,18 +302,21 @@ def coallesce
combined = 0
srch = frelst
while srch
while srch and srch=>frenxt
if srch + srch=>fresiz == srch=>frenxt
//
// Combine adjacent free space
//
srch=>fresiz = srch=>fresiz + srch=>frenxt=>fresiz
srch=>frenxt = srch=>frenxt=>frenxt
if srch=>frenxt
srch=>frenxt=>freprv = srch
fin
combined = 1
combined = 1
//putc('C')
else
srch = srch=>frenxt
fin
srch = srch=>frenxt
loop
return combined
end
@ -327,12 +330,13 @@ def compact
for entry = 255 downto 0
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
memblk = hpgtbl:[page, entry]
size = memblk=>blksiz << 4
size = memblk=>blksiz
moveblk = 0
srch = frelst
while srch and srch < memblk
if srch=>fresiz >= size
moveblk = unfre(srch)
moveblk = unfre(srch, size)
//putc('M');putc(' ');puth(moveblk);putc('=');puth(memblk);putln
break
fin
srch = srch=>frenxt
@ -345,7 +349,8 @@ def compact
fin
fin
next
break
else
break
fin
next
if moved
@ -359,7 +364,7 @@ end
def swapout(accessed)
byte[64] filename
byte ref
word page, entry, memblk, size, hmem
word page, entry, memblk, hmem, size
byte swapped
swapped = 0
@ -368,32 +373,34 @@ def swapout(accessed)
for entry = 255 downto 0
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
memblk = hpgtbl:[page, entry]
if not memblk->blklok & accessed
if not (memblk->blklok & accessed)
//
// Swap this block out
//
size = memblk=>blksiz << 4
size = memblk=>blksiz
hmem.lsb = page
hmem.msb = entry
swapfile(@filename, hmem)
create(@filename, $C3, $00, $0000)
//puts(@swapoutstr);puts(@filename);putc('@');puth(memblk);putc(':');puth(size);putln
create(@filename, $C3, $00, size) // embed size in aux type
ref = open(@filename)
if ref
//
// Write it out
//
if write(ref, memblk, size) == 0
if write(ref, memblk, size) == size
hpgtbl:[page, entry] = HMEM_SWAPPED
addfre(memblk)
swapped = 1
fin
close(ref)
fin
close(ref)
fin
fin
next
break
fin
else
break
fin
next
if swapped
coallesce
@ -404,10 +411,33 @@ end
//
// Find a memory block
//
def getblk(size)
def findexact(size)
word srch
srch = frelst
while srch
if srch=>fresiz == size
//putc('E')
return unlink(srch)
fin
srch = srch=>frenxt
loop
end
def findbest(size)
word srch, shrink
srch = frelst
while srch
if srch=>fresiz >= size
//putc('B')
return unfre(srch, size)
fin
srch = srch=>frenxt
loop
end
def findblk(size)
word addr
size = ((size + t_memblk) | MIN_BLK_MASK) + 1
if size > MAX_BLK_SIZE; return 0; fin
addr = findexact(size)
if !addr
@ -429,42 +459,58 @@ def getblk(size)
//
// Fill in the block
//
//puts(@getblkstr);puth(addr);putc(':');puth(size);putln
if addr
addr->blksiz = size >> 4
addr=>blksiz = size
addr->blkref = 1
addr->blklok = 0
fin
return addr
end
//
// Swap in a memory block
// Swap in a memory block (or allocate an uninitialized block)
//
def swapin(hmem)
byte[64] filename
byte[15] info
byte ref
word memblk, size
memblk = 0
if hpgtbl:[hmem.lsb, hmem.msb].lsb == HMEM_SWAPPED
//
// Swap this block back in
//
swapfile(@filename, hmem)
ref = open(@filename)
if ref
size = get_eof(ref)
memblk = getblk(size - t_memblk - 1)
when hpgtbl:[hmem.lsb, hmem.msb].lsb & HMEM_STATE
is HMEM_SWAPPED
//
// Swap this block back in
//
// Read it in
swapfile(@filename, hmem)
get_info(@filename, @info)
size = info:2 // size encoded in aux type
memblk = findblk(size)
if memblk
//
// Read it in
//
ref = open(@filename)
if ref
read(ref, memblk, size)
hpgtbl:[hmem.lsb, hmem.msb] = memblk
close(ref)
destroy(@filename)
else
memblk = 0
fin
fin
//puts(@swapinstr);puts(@filename);putc('@');puth(memblk);putc(':');puth(size);putln
break
is HMEM_UNINIT
//
// Initialize this block
//
memblk = findblk(hpgtbl:[hmem.lsb, hmem.msb] & HMEM_SIZE)
if memblk
hpgtbl:[hmem.lsb, hmem.msb] = memblk
read(ref, memblk, size)
fin
close(ref)
destroy(@filename)
fin
fin
wend
return memblk
end
//
@ -485,54 +531,55 @@ export def sweep
wend
if sweepen == 255
sweepen = 0
if sweeppg == PG_TBL_SIZE - 1
sweeppg = 0
if sweeppg == 0
sweeppg = PG_TBL_SIZE - 1
else
sweeppg = sweeppg + 1
sweeppg = sweeppg - 1
fin
else
sweepen = sweepen + 1
fin
else
if sweeppg == PG_TBL_SIZE - 1
sweeppg = 0
else
sweeppg = sweeppg + 1
fin
sweeppg = PG_TBL_SIZE - 1
fin
end
//
// Set end of memory pool
//
export def brk(addr)
word brksiz, brkblk, srch
word heapalign, brkblk, brksiz, srch
//
// Check if addr is too high or low
//
if isugt(addr, @brksiz); return 0; fin
if isuge(addr, @heapalign); return 0; fin
if isule(addr, heapmark); return 0; fin
brksiz = 0
if not pooladdr
//
// Allocate the memory pool
//
brksiz = addr - heapmark
heapalign = (heapmark | MIN_BLK_MASK) + 1
brksiz = addr - heapalign
if isult(brksiz, MAX_BLK_SIZE); return 0; fin // Not enough heap
poolsize = brksiz
pooladdr = heapalloc(poolsize)
frelst = pooladdr
frelst=>fresiz = poolsize
frelst=>frenxt = 0
frelst=>freprv = 0
poolsize = addr - heapmark
pooladdr = heapalloc(poolsize)
if pooladdr
frelst = heapalign
frelst=>fresiz = brksiz
frelst=>frenxt = 0
frelst=>freprv = 0
else
poolsize = 0
fin
else
//
// Can we extend the memory pool?
//
if pooladdr + poolsize == heapmark
brksiz = addr - heapmark
if isuge(brksiz, MIN_BLK_SIZE)
brkblk = heapalloc(brksiz)
brkblk = heapalloc(brksiz)
if brkblk
poolsize = poolsize + brksiz
//
// Add block to end of free list
//
@ -547,15 +594,46 @@ export def brk(addr)
frelst = brkblk
brkblk=>freprv = 0
fin
coallesce // combine adjacent free space
fin
fin
fin
return brksiz
return poolsize
end
export def sbrk(size)
return brk(heapmark + size)
end
//
// Return the amount of free memory available
//
export def hmemAvail
word srch, free
free = 0
srch = frelst
while srch
free = free + srch=>fresiz
srch = srch=>frenxt
loop
return free
end
export def hmemLargestAvail
word srch, largest
coallesce
while compact; loop
largest = 0
srch = frelst
while srch
//putc('F'); putc(' '); puth(srch); putc(':'); puth(srch=>fresiz); putln
if srch=>fresiz > largest
largest = srch=>fresiz
fin
srch = srch=>frenxt
loop
return largest
end
//
// Allocate memory block
//
export def hmemNew(size)
@ -571,6 +649,7 @@ export def hmemNew(size)
//
hpgtbl[page] = heapalloc(PG_SIZE)
memset(hpgtbl[page], PG_SIZE, HMEM_AVAIL)
//puts(@allocpgstr);puth(hpgtbl[page]);putln
//
// Check if we need to allocate the memory pool
//
@ -582,17 +661,20 @@ export def hmemNew(size)
if MACHID & $30 == $30
poolsize = poolsize + (poolsize >> 1)
fin
if isult(poolsize, MAX_BLK_SIZE + MIN_BLK_SIZE)
poolsize = MAX_BLK_SIZE + MIN_BLK_SIZE
fin
sbrk(poolsize)
fin
fin
for entry = 255 downto 0
if hpgtbl:[page, entry].lsb == HMEM_AVAIL
//
// Search for the best match
// Reserve handle as uninitialized memory
//
memblk = getblk(size)
if !memblk; return 0; fin
hpgtbl:[page, entry] = memblk
//putc('N');putc(' ');putb(entry);putb(page);putc('@')
size = ((size + t_memblk) | MIN_BLK_MASK) + 1
hpgtbl:[page, entry] = size | HMEM_UNINIT
hnew.lsb = page
hnew.msb = entry
return hnew
@ -608,6 +690,7 @@ export def hmemLock(hmem)
memblk = hpgtbl:[hmem.lsb, hmem.msb]
when memblk.lsb & HMEM_STATE
is HMEM_UNINIT
is HMEM_SWAPPED
memblk = swapin(hmem)
if not memblk; return 0; fin
@ -616,6 +699,7 @@ export def hmemLock(hmem)
is HMEM_LOCKED
memblk = memblk & HMEM_ADDR
memblk->blklok = (memblk->blklok + 1) | HMEM_ACCESSED
//putc('L');putc(' ');puth(hmem);putc('@');puth(memblk);putln
return memblk + t_memblk
wend
end
@ -637,6 +721,7 @@ export def hmemUnlock(hmem)
hpgtbl:[hmem.lsb, hmem.msb] = memblk
fin
memblk->blklok = lock
//putc('U');putc(' ');puth(hmem);putln
fin
end
//
@ -647,6 +732,7 @@ export def hmemRef(hmem)
memblk = hpgtbl:[hmem.lsb, hmem.msb]
when memblk.lsb & HMEM_STATE
is HMEM_UNINIT
is HMEM_SWAPPED
memblk = swapin(hmem)
is HMEM_LOCKED
@ -659,7 +745,7 @@ end
//
// Decrement reference count
//
export def hmemUnref(hmem)
export def hmemDel(hmem)
byte ref
word memblk
@ -681,29 +767,13 @@ export def hmemUnref(hmem)
else
memblk->blkref = ref
fin
break
is HMEM_UNINIT
hpgtbl:[hmem.lsb, hmem.msb] = HMEM_AVAIL
wend
end
//
// DEBUG
//
def putln
return putc($0D)
end
def putb(hexb)
return call($FDDA, hexb, 0, 0, 0)
end
def puth(hex)
return call($F941, hex >> 8, hex, 0, 0)
end
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
// Initialization:
//
// Search for best swap volume
//
@ -717,8 +787,8 @@ for sweepen = 0 to 15
if ^initdata=>volptr
memcpy(@swapvol + 2, initdata=>volptr + 1, ^initdata=>volptr)
swapvol = ^initdata=>volptr + 1
get_info(@swapvol, @initdata->info)
initdata=>freeblks = initdata=>info:2 - initdata=>info:5
get_info(@swapvol, @initdata->volinfo)
initdata=>freeblks = initdata=>volinfo:2 - initdata=>volinfo:5
if initdata=>volptr:1 == $522F and initdata=>volptr:3 == $4D41 // '/RAM'
if isugt(initdata=>freeblks, initdata=>ramfree)
initdata=>ramvol = initdata=>volptr

View File

@ -16,12 +16,14 @@ ROGUEIO = ROGUEIO\#FE1000
ROGUEMAP= ROGUEMAP\#FE1000
ROGUECOMBAT= ROGUECOMBAT\#FE1000
HELLO = HELLO\#FE1000
MON = MON\#FE1000
HGR1 = HGR1\#FE1000
HGR1TEST= HGR1TEST\#FE1000
TEST = TEST\#FE1000
TESTLIB = TESTLIB\#FE1000
PROFILE = PROFILE\#FE1000
MEMMGR = MEMMGR\#FE1000
MEMTEST = MEMTEST\#FE1000
PLASM = plasm
INCS = toolsrc/tokens.h toolsrc/symbols.h toolsrc/lex.h toolsrc/parse.h toolsrc/codegen.h
OBJS = toolsrc/plasm.c toolsrc/parse.o toolsrc/lex.o toolsrc/codegen.o
@ -41,7 +43,7 @@ TXTTYPE = .TXT
#SYSTYPE = \#FF2000
#TXTTYPE = \#040000
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(MEMMGR) $(SB) $(ROD) $(SIEVE) $(UTHERNET) $(ETHERIP) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1)
all: $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03) $(CMD) $(MEMMGR) $(MEMTEST) $(SB) $(MON) $(ROD) $(SIEVE) $(UTHERNET) $(ETHERIP) $(ROGUE) $(ROGUEMAP) $(ROGUECOMBAT) $(ROGUEIO) $(HGR1)
clean:
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03)
@ -102,6 +104,14 @@ $(MEMMGR): libsrc/memmgr.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < libsrc/memmgr.pla > libsrc/memmgr.a
acme --setpc 4094 -o $(MEMMGR) libsrc/memmgr.a
$(MEMTEST): samplesrc/memtest.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/memtest.pla > samplesrc/memtest.a
acme --setpc 4094 -o $(MEMTEST) samplesrc/memtest.a
$(MON): samplesrc/mon.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/mon.pla > samplesrc/mon.a
acme --setpc 4094 -o $(MON) samplesrc/mon.a
$(ROD): samplesrc/rod.pla $(PLVM02) $(PLASM)
./$(PLASM) -AM < samplesrc/rod.pla > samplesrc/rod.a
acme --setpc 4094 -o $(ROD) samplesrc/rod.a

78
src/samplesrc/memtest.pla Normal file
View File

@ -0,0 +1,78 @@
import stdlib
predef syscall, call, memset, getc, gets, putc, puts, putln
predef memset, memcpy, modaddr, modexec
predef heapmark, heapallocalign, heapalloc, heaprelease
predef isugt, isuge, isult, isule
byte MACHID
end
import memmgr
predef sweep, brk, sbrk
predef hmemNew, hmemLock, hmemUnlock, hmemRef, hmemDel, hmemAvail, hmemLargestAvail
const MAX_MEMBLK_SIZE = $2000
end
word a, b, c, d, e, memptr
def putln
return putc($0D)
end
def putb(hexb)
return call($FDDA, hexb, 0, 0, 0)
end
def puth(hex)
return call($F941, hex >> 8, hex, 0, 0)
end
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
sbrk($3000) // Set small pool size
puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
a = hmemNew(MAX_MEMBLK_SIZE)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
b = hmemNew(MAX_MEMBLK_SIZE)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
c = hmemNew(MAX_MEMBLK_SIZE)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
d = hmemNew(100)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
memptr = hmemLock(a)
if memptr; memset(memptr, MAX_MEMBLK_SIZE, $1111); fin
hmemUnlock(a)
memptr = hmemLock(b)
if memptr; memset(memptr, MAX_MEMBLK_SIZE, $2222); fin
hmemUnlock(b)
memptr = hmemLock(c)
if memptr; memset(memptr, MAX_MEMBLK_SIZE, $3333); fin
hmemUnlock(c)
memptr = hmemLock(a)
if memptr; puth(a); putc('='); puth(*(memptr + MAX_MEMBLK_SIZE - 2)); putln; fin
hmemUnlock(a)
hmemDel(a)
hmemLock(d)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
e = hmemNew(240)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
hmemLock(e)
hmemUnlock(d)
memptr = hmemLock(b)
if memptr; puth(b); putc('='); puth(*(memptr + MAX_MEMBLK_SIZE - 2)); putln; fin
hmemUnlock(b)
hmemUnlock(e)
hmemDel(b)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
memptr = hmemLock(c)
if memptr; puth(c); putc('='); puth(*(memptr + MAX_MEMBLK_SIZE - 2)); putln; fin
hmemUnlock(c)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
hmemDel(c)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
hmemDel(e)
//puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
hmemDel(d)
puth(hmemAvail); putc(' '); puth(hmemLargestAvail); putln
done

View File

@ -397,19 +397,13 @@ int parse_value(int rvalue)
if (deref)
push_op(scantoken, 0);
else
{
type |= BPTR_TYPE;
deref++;
}
break;
case WPTR_TOKEN:
if (deref)
push_op(scantoken, 0);
else
{
type |= WPTR_TYPE;
deref++;
}
break;
case AT_TOKEN:
deref--;
@ -694,10 +688,20 @@ int parse_value(int rvalue)
{
if (type & CONST_TYPE)
emit_const(value);
else if (type & LOCAL_TYPE)
emit_localaddr(value + ref_offset);
else
emit_globaladdr(value, ref_offset, ref_type);
else if (type & ADDR_TYPE)
{
if (type & PTR_TYPE)
{
if (type & LOCAL_TYPE)
(type & BYTE_TYPE) ? emit_llb(value + ref_offset) : emit_llw(value + ref_offset);
else
(type & BYTE_TYPE) ? emit_lab(value, ref_offset, ref_type) : emit_law(value, ref_offset, ref_type);
}
else if (type & LOCAL_TYPE)
emit_localaddr(value + ref_offset);
else
emit_globaladdr(value, ref_offset, ref_type);
}
}
}
while (optos < opsptr)

View File

@ -1,4 +1,3 @@
//
// Global constants
//
@ -65,9 +64,9 @@ const strlinbuf = $1000
const strheapmap = $1500
const strheapmsz = $80 // = memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map
const maxlnlen = 79
const strheap = $6800
const strheap = $6900
const strheasz = $4000
const codebuff = $A800
const codebuff = $A900
const codebuffsz = $1000
const pgjmp = 16
const changed = 1
@ -3109,7 +3108,6 @@ def parse_value(rvalue)
push_op(token, 0)
else
type = type | BPTR_TYPE
deref = deref + 1
fin
break
is WPTR_TKN
@ -3117,7 +3115,6 @@ def parse_value(rvalue)
push_op(token, 0)
else
type = type | WPTR_TYPE
deref = deref + 1
fin
break
is AT_TKN
@ -3191,6 +3188,11 @@ def parse_value(rvalue)
// Function call
//
if emit_val
if ref_offset <> 0
emit_const(ref_offset)
emit_op($02)
ref_offset = 0
fin
if ref_type & BPTR_TYPE; emit_lb
elsif ref_type & WPTR_TYPE; emit_lw; fin
if lookahead <> CLOSE_PAREN_TKN
@ -3247,6 +3249,14 @@ def parse_value(rvalue)
ref_offset = 0
fin
emit_val = TRUE
else
if ref_offset <> 0
emit_const(ref_offset)
emit_op($02)
ref_offset = 0
fin
if ref_type & BPTR_TYPE; emit_lb
elsif ref_type & WPTR_TYPE; emit_lw; fin
fin
while parse_expr
if token <> COMMA_TKN
@ -3290,6 +3300,14 @@ def parse_value(rvalue)
fin
fin
emit_val = 1;
else
if ref_offset <> 0
emit_const(ref_offset)
emit_op($02)
ref_offset = 0
fin
if ref_type & BPTR_TYPE; emit_lb
elsif ref_type & WPTR_TYPE; emit_lw; fin
fin
if token == PTRB_TKN
ref_type = BPTR_TYPE
@ -3338,24 +3356,21 @@ def parse_value(rvalue)
ref_offset = 0
emit_val = TRUE
fin
else
if ref_offset <> 0
emit_const(ref_offset)
emit_op($02)
ref_offset = 0
fin
fin
fin
break
wend
loop
if emit_val
if rvalue
if deref and ref_type & PTR_TYPE
if ref_type & BPTR_TYPE
emit_lb
else
emit_lw
fin
if ref_offset <> 0
emit_const(ref_offset)
emit_op($02)
ref_offset = 0
fin
if deref and ref_type & PTR_TYPE
if ref_type & BPTR_TYPE
emit_lb
else
emit_lw
fin
fin
else // emit_val
@ -3389,16 +3404,35 @@ def parse_value(rvalue)
else
if type & CONST_TYPE
emit_const(value)
elsif type & LOCAL_TYPE
emit_localaddr(value + ref_offset)
else
emit_globaladdr(value, ref_offset)
elsif type & ADDR_TYPE
if type & PTR_TYPE
if type & LOCAL_TYPE
if type & BYTE_TYPE
emit_llb(value + ref_offset)
else
emit_llw(value + ref_offset)
fin
else
if type & BYTE_TYPE
emit_lab(value, ref_offset)
else
emit_law(value, ref_offset)
fin
fin
elsif type & LOCAL_TYPE
emit_localaddr(value + ref_offset)
else
emit_globaladdr(value, ref_offset)
fin
fin
fin
fin // emit_val
while optos < opsp
if !emit_unaryop(pop_op); return parse_err(@bad_op); fin
loop
if type & PTR_TYPE
ref_type = type
fin
if !ref_type
ref_type = WORD_TYPE
fin