mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-02-09 04:30:37 +00:00
memory manager tester and more parse_value fixes
This commit is contained in:
parent
8ff8a37a68
commit
06a7f9d0e3
14
src/inc/memmgr.plh
Normal file
14
src/inc/memmgr.plh
Normal 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
|
@ -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 syscall, call, memset, getc, gets, putc, puts, putln
|
||||||
predef memset, memcpy, modaddr, modexec
|
predef memset, memcpy, modaddr, modexec
|
||||||
predef heapmark, heapallocalign, heapalloc, heaprelease
|
predef heapmark, heapallocalign, heapalloc, heaprelease
|
||||||
@ -23,7 +23,7 @@ struc t_initdata
|
|||||||
byte entrylen
|
byte entrylen
|
||||||
byte entriesblk
|
byte entriesblk
|
||||||
byte swapstrlen
|
byte swapstrlen
|
||||||
byte[] info
|
byte[] volinfo
|
||||||
byte[] catalog
|
byte[] catalog
|
||||||
end
|
end
|
||||||
word initdata
|
word initdata
|
||||||
@ -38,7 +38,7 @@ end
|
|||||||
// Alloced memory block structure
|
// Alloced memory block structure
|
||||||
//
|
//
|
||||||
struc t_memblk
|
struc t_memblk
|
||||||
byte blksiz
|
word blksiz
|
||||||
byte blkref
|
byte blkref
|
||||||
byte blklok
|
byte blklok
|
||||||
end
|
end
|
||||||
@ -53,19 +53,21 @@ end
|
|||||||
//
|
//
|
||||||
// Block size
|
// Block size
|
||||||
//
|
//
|
||||||
const MAX_BLK_SIZE = $0FE0
|
const MAX_BLK_SIZE = $2010
|
||||||
const MAX_BLK_MASK = $0FF0
|
const MAX_BLK_MASK = $1FFF
|
||||||
const MIN_BLK_SIZE = $10
|
const MIN_BLK_SIZE = $08
|
||||||
const MIN_BLK_MASK = $0F
|
const MIN_BLK_MASK = $07
|
||||||
//
|
//
|
||||||
// Block states
|
// Block states
|
||||||
//
|
//
|
||||||
const HMEM_ADDR = $FFFC
|
const HMEM_ADDR = $FFF8
|
||||||
const HMEM_STATE = $03
|
const HMEM_SIZE = $FFF8
|
||||||
|
const HMEM_STATE = $07
|
||||||
const HMEM_MOVEABLE = $00 // Many dependencies on this being $00
|
const HMEM_MOVEABLE = $00 // Many dependencies on this being $00
|
||||||
const HMEM_AVAIL = $01
|
const HMEM_AVAIL = $01
|
||||||
const HMEM_LOCKED = $02
|
const HMEM_LOCKED = $02
|
||||||
const HMEM_SWAPPED = $03
|
const HMEM_SWAPPED = $03
|
||||||
|
const HMEM_UNINIT = $04
|
||||||
//
|
//
|
||||||
// Block flags
|
// Block flags
|
||||||
//
|
//
|
||||||
@ -89,11 +91,37 @@ byte[64] swapvol = "/" // Swap volume
|
|||||||
byte swapdir = "/SWAP/"
|
byte swapdir = "/SWAP/"
|
||||||
byte hexchar = '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
|
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
|
// Fill block filename
|
||||||
//
|
//
|
||||||
def strcharadd(str, char)
|
def strcharadd(str, char)
|
||||||
^str = ^str + 1
|
^str = ^str + 1
|
||||||
str->[^str] = char
|
str->.[^str] = char
|
||||||
end
|
end
|
||||||
def swapfile(filestr, hmem)
|
def swapfile(filestr, hmem)
|
||||||
memcpy(filestr, @swapvol, swapvol + 1)
|
memcpy(filestr, @swapvol, swapvol + 1)
|
||||||
@ -142,16 +170,6 @@ def write(refnum, buff, len)
|
|||||||
syscall($CB, @params)
|
syscall($CB, @params)
|
||||||
return params:6
|
return params:6
|
||||||
end
|
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)
|
def get_info(path, infoptr)
|
||||||
byte params[18]
|
byte params[18]
|
||||||
|
|
||||||
@ -242,7 +260,7 @@ end
|
|||||||
def addfre(freblk)
|
def addfre(freblk)
|
||||||
word srch
|
word srch
|
||||||
|
|
||||||
freblk=>fresiz = freblk=>blksiz << 4
|
//freblk=>fresiz = freblk=>blksiz
|
||||||
if frelst and frelst < freblk
|
if frelst and frelst < freblk
|
||||||
srch = frelst
|
srch = frelst
|
||||||
while srch=>frenxt
|
while srch=>frenxt
|
||||||
@ -254,6 +272,7 @@ def addfre(freblk)
|
|||||||
freblk=>frenxt = srch=>frenxt
|
freblk=>frenxt = srch=>frenxt
|
||||||
srch=>frenxt=>freprv = freblk
|
srch=>frenxt=>freprv = freblk
|
||||||
srch=>frenxt = freblk
|
srch=>frenxt = freblk
|
||||||
|
return
|
||||||
fin
|
fin
|
||||||
srch = srch=>frenxt
|
srch = srch=>frenxt
|
||||||
loop
|
loop
|
||||||
@ -268,32 +287,13 @@ def addfre(freblk)
|
|||||||
// Add to beginning of list
|
// Add to beginning of list
|
||||||
//
|
//
|
||||||
freblk=>freprv = 0
|
freblk=>freprv = 0
|
||||||
freblk=>frenxt = frelst
|
freblk=>frenxt = frelst
|
||||||
frelst = freblk
|
if frelst
|
||||||
|
frelst=>freprv = freblk
|
||||||
|
fin
|
||||||
|
frelst = freblk
|
||||||
fin
|
fin
|
||||||
end
|
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
|
// Memory coallesce/compaction/swap out routines
|
||||||
//
|
//
|
||||||
@ -302,18 +302,21 @@ def coallesce
|
|||||||
|
|
||||||
combined = 0
|
combined = 0
|
||||||
srch = frelst
|
srch = frelst
|
||||||
while srch
|
while srch and srch=>frenxt
|
||||||
if srch + srch=>fresiz == srch=>frenxt
|
if srch + srch=>fresiz == srch=>frenxt
|
||||||
//
|
//
|
||||||
// Combine adjacent free space
|
// Combine adjacent free space
|
||||||
//
|
//
|
||||||
|
srch=>fresiz = srch=>fresiz + srch=>frenxt=>fresiz
|
||||||
srch=>frenxt = srch=>frenxt=>frenxt
|
srch=>frenxt = srch=>frenxt=>frenxt
|
||||||
if srch=>frenxt
|
if srch=>frenxt
|
||||||
srch=>frenxt=>freprv = srch
|
srch=>frenxt=>freprv = srch
|
||||||
fin
|
fin
|
||||||
combined = 1
|
combined = 1
|
||||||
|
//putc('C')
|
||||||
|
else
|
||||||
|
srch = srch=>frenxt
|
||||||
fin
|
fin
|
||||||
srch = srch=>frenxt
|
|
||||||
loop
|
loop
|
||||||
return combined
|
return combined
|
||||||
end
|
end
|
||||||
@ -327,12 +330,13 @@ def compact
|
|||||||
for entry = 255 downto 0
|
for entry = 255 downto 0
|
||||||
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
|
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
|
||||||
memblk = hpgtbl:[page, entry]
|
memblk = hpgtbl:[page, entry]
|
||||||
size = memblk=>blksiz << 4
|
size = memblk=>blksiz
|
||||||
moveblk = 0
|
moveblk = 0
|
||||||
srch = frelst
|
srch = frelst
|
||||||
while srch and srch < memblk
|
while srch and srch < memblk
|
||||||
if srch=>fresiz >= size
|
if srch=>fresiz >= size
|
||||||
moveblk = unfre(srch)
|
moveblk = unfre(srch, size)
|
||||||
|
//putc('M');putc(' ');puth(moveblk);putc('=');puth(memblk);putln
|
||||||
break
|
break
|
||||||
fin
|
fin
|
||||||
srch = srch=>frenxt
|
srch = srch=>frenxt
|
||||||
@ -345,7 +349,8 @@ def compact
|
|||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
next
|
next
|
||||||
break
|
else
|
||||||
|
break
|
||||||
fin
|
fin
|
||||||
next
|
next
|
||||||
if moved
|
if moved
|
||||||
@ -359,7 +364,7 @@ end
|
|||||||
def swapout(accessed)
|
def swapout(accessed)
|
||||||
byte[64] filename
|
byte[64] filename
|
||||||
byte ref
|
byte ref
|
||||||
word page, entry, memblk, size, hmem
|
word page, entry, memblk, hmem, size
|
||||||
byte swapped
|
byte swapped
|
||||||
|
|
||||||
swapped = 0
|
swapped = 0
|
||||||
@ -368,32 +373,34 @@ def swapout(accessed)
|
|||||||
for entry = 255 downto 0
|
for entry = 255 downto 0
|
||||||
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
|
if hpgtbl:[page, entry].lsb & HMEM_STATE == HMEM_MOVEABLE
|
||||||
memblk = hpgtbl:[page, entry]
|
memblk = hpgtbl:[page, entry]
|
||||||
if not memblk->blklok & accessed
|
if not (memblk->blklok & accessed)
|
||||||
//
|
//
|
||||||
// Swap this block out
|
// Swap this block out
|
||||||
//
|
//
|
||||||
size = memblk=>blksiz << 4
|
size = memblk=>blksiz
|
||||||
hmem.lsb = page
|
hmem.lsb = page
|
||||||
hmem.msb = entry
|
hmem.msb = entry
|
||||||
swapfile(@filename, hmem)
|
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)
|
ref = open(@filename)
|
||||||
if ref
|
if ref
|
||||||
//
|
//
|
||||||
// Write it out
|
// Write it out
|
||||||
//
|
//
|
||||||
if write(ref, memblk, size) == 0
|
if write(ref, memblk, size) == size
|
||||||
hpgtbl:[page, entry] = HMEM_SWAPPED
|
hpgtbl:[page, entry] = HMEM_SWAPPED
|
||||||
addfre(memblk)
|
addfre(memblk)
|
||||||
swapped = 1
|
swapped = 1
|
||||||
fin
|
fin
|
||||||
|
close(ref)
|
||||||
fin
|
fin
|
||||||
close(ref)
|
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
next
|
next
|
||||||
break
|
else
|
||||||
fin
|
break
|
||||||
|
fin
|
||||||
next
|
next
|
||||||
if swapped
|
if swapped
|
||||||
coallesce
|
coallesce
|
||||||
@ -404,10 +411,33 @@ end
|
|||||||
//
|
//
|
||||||
// Find a memory block
|
// 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
|
word addr
|
||||||
|
|
||||||
size = ((size + t_memblk) | MIN_BLK_MASK) + 1
|
|
||||||
if size > MAX_BLK_SIZE; return 0; fin
|
if size > MAX_BLK_SIZE; return 0; fin
|
||||||
addr = findexact(size)
|
addr = findexact(size)
|
||||||
if !addr
|
if !addr
|
||||||
@ -429,42 +459,58 @@ def getblk(size)
|
|||||||
//
|
//
|
||||||
// Fill in the block
|
// Fill in the block
|
||||||
//
|
//
|
||||||
|
//puts(@getblkstr);puth(addr);putc(':');puth(size);putln
|
||||||
if addr
|
if addr
|
||||||
addr->blksiz = size >> 4
|
addr=>blksiz = size
|
||||||
addr->blkref = 1
|
addr->blkref = 1
|
||||||
addr->blklok = 0
|
addr->blklok = 0
|
||||||
fin
|
fin
|
||||||
return addr
|
return addr
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Swap in a memory block
|
// Swap in a memory block (or allocate an uninitialized block)
|
||||||
//
|
//
|
||||||
def swapin(hmem)
|
def swapin(hmem)
|
||||||
byte[64] filename
|
byte[64] filename
|
||||||
|
byte[15] info
|
||||||
byte ref
|
byte ref
|
||||||
word memblk, size
|
word memblk, size
|
||||||
|
|
||||||
memblk = 0
|
memblk = 0
|
||||||
if hpgtbl:[hmem.lsb, hmem.msb].lsb == HMEM_SWAPPED
|
when hpgtbl:[hmem.lsb, hmem.msb].lsb & HMEM_STATE
|
||||||
//
|
is HMEM_SWAPPED
|
||||||
// Swap this block back in
|
//
|
||||||
//
|
// Swap this block back in
|
||||||
swapfile(@filename, hmem)
|
|
||||||
ref = open(@filename)
|
|
||||||
if ref
|
|
||||||
size = get_eof(ref)
|
|
||||||
memblk = getblk(size - t_memblk - 1)
|
|
||||||
//
|
//
|
||||||
// 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
|
if memblk
|
||||||
hpgtbl:[hmem.lsb, hmem.msb] = memblk
|
hpgtbl:[hmem.lsb, hmem.msb] = memblk
|
||||||
read(ref, memblk, size)
|
|
||||||
fin
|
fin
|
||||||
close(ref)
|
wend
|
||||||
destroy(@filename)
|
|
||||||
fin
|
|
||||||
fin
|
|
||||||
return memblk
|
return memblk
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
@ -485,54 +531,55 @@ export def sweep
|
|||||||
wend
|
wend
|
||||||
if sweepen == 255
|
if sweepen == 255
|
||||||
sweepen = 0
|
sweepen = 0
|
||||||
if sweeppg == PG_TBL_SIZE - 1
|
if sweeppg == 0
|
||||||
sweeppg = 0
|
sweeppg = PG_TBL_SIZE - 1
|
||||||
else
|
else
|
||||||
sweeppg = sweeppg + 1
|
sweeppg = sweeppg - 1
|
||||||
fin
|
fin
|
||||||
else
|
else
|
||||||
sweepen = sweepen + 1
|
sweepen = sweepen + 1
|
||||||
fin
|
fin
|
||||||
else
|
else
|
||||||
if sweeppg == PG_TBL_SIZE - 1
|
sweeppg = PG_TBL_SIZE - 1
|
||||||
sweeppg = 0
|
|
||||||
else
|
|
||||||
sweeppg = sweeppg + 1
|
|
||||||
fin
|
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Set end of memory pool
|
// Set end of memory pool
|
||||||
//
|
//
|
||||||
export def brk(addr)
|
export def brk(addr)
|
||||||
word brksiz, brkblk, srch
|
word heapalign, brkblk, brksiz, srch
|
||||||
|
|
||||||
//
|
//
|
||||||
// Check if addr is too high or low
|
// 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
|
if isule(addr, heapmark); return 0; fin
|
||||||
brksiz = 0
|
|
||||||
if not pooladdr
|
if not pooladdr
|
||||||
//
|
//
|
||||||
// Allocate the memory pool
|
// 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
|
if isult(brksiz, MAX_BLK_SIZE); return 0; fin // Not enough heap
|
||||||
poolsize = brksiz
|
poolsize = addr - heapmark
|
||||||
pooladdr = heapalloc(poolsize)
|
pooladdr = heapalloc(poolsize)
|
||||||
frelst = pooladdr
|
if pooladdr
|
||||||
frelst=>fresiz = poolsize
|
frelst = heapalign
|
||||||
frelst=>frenxt = 0
|
frelst=>fresiz = brksiz
|
||||||
frelst=>freprv = 0
|
frelst=>frenxt = 0
|
||||||
|
frelst=>freprv = 0
|
||||||
|
else
|
||||||
|
poolsize = 0
|
||||||
|
fin
|
||||||
else
|
else
|
||||||
//
|
//
|
||||||
// Can we extend the memory pool?
|
// Can we extend the memory pool?
|
||||||
//
|
//
|
||||||
if pooladdr + poolsize == heapmark
|
if pooladdr + poolsize == heapmark
|
||||||
brksiz = addr - 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
|
// Add block to end of free list
|
||||||
//
|
//
|
||||||
@ -547,15 +594,46 @@ export def brk(addr)
|
|||||||
frelst = brkblk
|
frelst = brkblk
|
||||||
brkblk=>freprv = 0
|
brkblk=>freprv = 0
|
||||||
fin
|
fin
|
||||||
|
coallesce // combine adjacent free space
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
return brksiz
|
return poolsize
|
||||||
end
|
end
|
||||||
export def sbrk(size)
|
export def sbrk(size)
|
||||||
return brk(heapmark + size)
|
return brk(heapmark + size)
|
||||||
end
|
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
|
// Allocate memory block
|
||||||
//
|
//
|
||||||
export def hmemNew(size)
|
export def hmemNew(size)
|
||||||
@ -571,6 +649,7 @@ export def hmemNew(size)
|
|||||||
//
|
//
|
||||||
hpgtbl[page] = heapalloc(PG_SIZE)
|
hpgtbl[page] = heapalloc(PG_SIZE)
|
||||||
memset(hpgtbl[page], PG_SIZE, HMEM_AVAIL)
|
memset(hpgtbl[page], PG_SIZE, HMEM_AVAIL)
|
||||||
|
//puts(@allocpgstr);puth(hpgtbl[page]);putln
|
||||||
//
|
//
|
||||||
// Check if we need to allocate the memory pool
|
// Check if we need to allocate the memory pool
|
||||||
//
|
//
|
||||||
@ -582,17 +661,20 @@ export def hmemNew(size)
|
|||||||
if MACHID & $30 == $30
|
if MACHID & $30 == $30
|
||||||
poolsize = poolsize + (poolsize >> 1)
|
poolsize = poolsize + (poolsize >> 1)
|
||||||
fin
|
fin
|
||||||
|
if isult(poolsize, MAX_BLK_SIZE + MIN_BLK_SIZE)
|
||||||
|
poolsize = MAX_BLK_SIZE + MIN_BLK_SIZE
|
||||||
|
fin
|
||||||
sbrk(poolsize)
|
sbrk(poolsize)
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
for entry = 255 downto 0
|
for entry = 255 downto 0
|
||||||
if hpgtbl:[page, entry].lsb == HMEM_AVAIL
|
if hpgtbl:[page, entry].lsb == HMEM_AVAIL
|
||||||
//
|
//
|
||||||
// Search for the best match
|
// Reserve handle as uninitialized memory
|
||||||
//
|
//
|
||||||
memblk = getblk(size)
|
//putc('N');putc(' ');putb(entry);putb(page);putc('@')
|
||||||
if !memblk; return 0; fin
|
size = ((size + t_memblk) | MIN_BLK_MASK) + 1
|
||||||
hpgtbl:[page, entry] = memblk
|
hpgtbl:[page, entry] = size | HMEM_UNINIT
|
||||||
hnew.lsb = page
|
hnew.lsb = page
|
||||||
hnew.msb = entry
|
hnew.msb = entry
|
||||||
return hnew
|
return hnew
|
||||||
@ -608,6 +690,7 @@ export def hmemLock(hmem)
|
|||||||
|
|
||||||
memblk = hpgtbl:[hmem.lsb, hmem.msb]
|
memblk = hpgtbl:[hmem.lsb, hmem.msb]
|
||||||
when memblk.lsb & HMEM_STATE
|
when memblk.lsb & HMEM_STATE
|
||||||
|
is HMEM_UNINIT
|
||||||
is HMEM_SWAPPED
|
is HMEM_SWAPPED
|
||||||
memblk = swapin(hmem)
|
memblk = swapin(hmem)
|
||||||
if not memblk; return 0; fin
|
if not memblk; return 0; fin
|
||||||
@ -616,6 +699,7 @@ export def hmemLock(hmem)
|
|||||||
is HMEM_LOCKED
|
is HMEM_LOCKED
|
||||||
memblk = memblk & HMEM_ADDR
|
memblk = memblk & HMEM_ADDR
|
||||||
memblk->blklok = (memblk->blklok + 1) | HMEM_ACCESSED
|
memblk->blklok = (memblk->blklok + 1) | HMEM_ACCESSED
|
||||||
|
//putc('L');putc(' ');puth(hmem);putc('@');puth(memblk);putln
|
||||||
return memblk + t_memblk
|
return memblk + t_memblk
|
||||||
wend
|
wend
|
||||||
end
|
end
|
||||||
@ -637,6 +721,7 @@ export def hmemUnlock(hmem)
|
|||||||
hpgtbl:[hmem.lsb, hmem.msb] = memblk
|
hpgtbl:[hmem.lsb, hmem.msb] = memblk
|
||||||
fin
|
fin
|
||||||
memblk->blklok = lock
|
memblk->blklok = lock
|
||||||
|
//putc('U');putc(' ');puth(hmem);putln
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
@ -647,6 +732,7 @@ export def hmemRef(hmem)
|
|||||||
|
|
||||||
memblk = hpgtbl:[hmem.lsb, hmem.msb]
|
memblk = hpgtbl:[hmem.lsb, hmem.msb]
|
||||||
when memblk.lsb & HMEM_STATE
|
when memblk.lsb & HMEM_STATE
|
||||||
|
is HMEM_UNINIT
|
||||||
is HMEM_SWAPPED
|
is HMEM_SWAPPED
|
||||||
memblk = swapin(hmem)
|
memblk = swapin(hmem)
|
||||||
is HMEM_LOCKED
|
is HMEM_LOCKED
|
||||||
@ -659,7 +745,7 @@ end
|
|||||||
//
|
//
|
||||||
// Decrement reference count
|
// Decrement reference count
|
||||||
//
|
//
|
||||||
export def hmemUnref(hmem)
|
export def hmemDel(hmem)
|
||||||
byte ref
|
byte ref
|
||||||
word memblk
|
word memblk
|
||||||
|
|
||||||
@ -681,29 +767,13 @@ export def hmemUnref(hmem)
|
|||||||
else
|
else
|
||||||
memblk->blkref = ref
|
memblk->blkref = ref
|
||||||
fin
|
fin
|
||||||
|
break
|
||||||
|
is HMEM_UNINIT
|
||||||
|
hpgtbl:[hmem.lsb, hmem.msb] = HMEM_AVAIL
|
||||||
wend
|
wend
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// DEBUG
|
// Initialization:
|
||||||
//
|
|
||||||
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
|
|
||||||
//
|
//
|
||||||
// Search for best swap volume
|
// Search for best swap volume
|
||||||
//
|
//
|
||||||
@ -717,8 +787,8 @@ for sweepen = 0 to 15
|
|||||||
if ^initdata=>volptr
|
if ^initdata=>volptr
|
||||||
memcpy(@swapvol + 2, initdata=>volptr + 1, ^initdata=>volptr)
|
memcpy(@swapvol + 2, initdata=>volptr + 1, ^initdata=>volptr)
|
||||||
swapvol = ^initdata=>volptr + 1
|
swapvol = ^initdata=>volptr + 1
|
||||||
get_info(@swapvol, @initdata->info)
|
get_info(@swapvol, @initdata->volinfo)
|
||||||
initdata=>freeblks = initdata=>info:2 - initdata=>info:5
|
initdata=>freeblks = initdata=>volinfo:2 - initdata=>volinfo:5
|
||||||
if initdata=>volptr:1 == $522F and initdata=>volptr:3 == $4D41 // '/RAM'
|
if initdata=>volptr:1 == $522F and initdata=>volptr:3 == $4D41 // '/RAM'
|
||||||
if isugt(initdata=>freeblks, initdata=>ramfree)
|
if isugt(initdata=>freeblks, initdata=>ramfree)
|
||||||
initdata=>ramvol = initdata=>volptr
|
initdata=>ramvol = initdata=>volptr
|
||||||
|
12
src/makefile
12
src/makefile
@ -16,12 +16,14 @@ ROGUEIO = ROGUEIO\#FE1000
|
|||||||
ROGUEMAP= ROGUEMAP\#FE1000
|
ROGUEMAP= ROGUEMAP\#FE1000
|
||||||
ROGUECOMBAT= ROGUECOMBAT\#FE1000
|
ROGUECOMBAT= ROGUECOMBAT\#FE1000
|
||||||
HELLO = HELLO\#FE1000
|
HELLO = HELLO\#FE1000
|
||||||
|
MON = MON\#FE1000
|
||||||
HGR1 = HGR1\#FE1000
|
HGR1 = HGR1\#FE1000
|
||||||
HGR1TEST= HGR1TEST\#FE1000
|
HGR1TEST= HGR1TEST\#FE1000
|
||||||
TEST = TEST\#FE1000
|
TEST = TEST\#FE1000
|
||||||
TESTLIB = TESTLIB\#FE1000
|
TESTLIB = TESTLIB\#FE1000
|
||||||
PROFILE = PROFILE\#FE1000
|
PROFILE = PROFILE\#FE1000
|
||||||
MEMMGR = MEMMGR\#FE1000
|
MEMMGR = MEMMGR\#FE1000
|
||||||
|
MEMTEST = MEMTEST\#FE1000
|
||||||
PLASM = plasm
|
PLASM = plasm
|
||||||
INCS = toolsrc/tokens.h toolsrc/symbols.h toolsrc/lex.h toolsrc/parse.h toolsrc/codegen.h
|
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
|
OBJS = toolsrc/plasm.c toolsrc/parse.o toolsrc/lex.o toolsrc/codegen.o
|
||||||
@ -41,7 +43,7 @@ TXTTYPE = .TXT
|
|||||||
#SYSTYPE = \#FF2000
|
#SYSTYPE = \#FF2000
|
||||||
#TXTTYPE = \#040000
|
#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:
|
clean:
|
||||||
-rm *FE1000 *FF2000 $(PLASM) $(PLVM) $(PLVM01) $(PLVM02) $(PLVM03)
|
-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
|
./$(PLASM) -AM < libsrc/memmgr.pla > libsrc/memmgr.a
|
||||||
acme --setpc 4094 -o $(MEMMGR) 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)
|
$(ROD): samplesrc/rod.pla $(PLVM02) $(PLASM)
|
||||||
./$(PLASM) -AM < samplesrc/rod.pla > samplesrc/rod.a
|
./$(PLASM) -AM < samplesrc/rod.pla > samplesrc/rod.a
|
||||||
acme --setpc 4094 -o $(ROD) samplesrc/rod.a
|
acme --setpc 4094 -o $(ROD) samplesrc/rod.a
|
||||||
|
78
src/samplesrc/memtest.pla
Normal file
78
src/samplesrc/memtest.pla
Normal 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
|
@ -397,19 +397,13 @@ int parse_value(int rvalue)
|
|||||||
if (deref)
|
if (deref)
|
||||||
push_op(scantoken, 0);
|
push_op(scantoken, 0);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
type |= BPTR_TYPE;
|
type |= BPTR_TYPE;
|
||||||
deref++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case WPTR_TOKEN:
|
case WPTR_TOKEN:
|
||||||
if (deref)
|
if (deref)
|
||||||
push_op(scantoken, 0);
|
push_op(scantoken, 0);
|
||||||
else
|
else
|
||||||
{
|
|
||||||
type |= WPTR_TYPE;
|
type |= WPTR_TYPE;
|
||||||
deref++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case AT_TOKEN:
|
case AT_TOKEN:
|
||||||
deref--;
|
deref--;
|
||||||
@ -694,10 +688,20 @@ int parse_value(int rvalue)
|
|||||||
{
|
{
|
||||||
if (type & CONST_TYPE)
|
if (type & CONST_TYPE)
|
||||||
emit_const(value);
|
emit_const(value);
|
||||||
else if (type & LOCAL_TYPE)
|
else if (type & ADDR_TYPE)
|
||||||
emit_localaddr(value + ref_offset);
|
{
|
||||||
else
|
if (type & PTR_TYPE)
|
||||||
emit_globaladdr(value, ref_offset, ref_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)
|
while (optos < opsptr)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Global constants
|
// Global constants
|
||||||
//
|
//
|
||||||
@ -65,9 +64,9 @@ const strlinbuf = $1000
|
|||||||
const strheapmap = $1500
|
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 strheapmsz = $80 // = memory@16 bytes per bit map, 128 bytes per 8 bit map, 1K bytes per 8 byte map
|
||||||
const maxlnlen = 79
|
const maxlnlen = 79
|
||||||
const strheap = $6800
|
const strheap = $6900
|
||||||
const strheasz = $4000
|
const strheasz = $4000
|
||||||
const codebuff = $A800
|
const codebuff = $A900
|
||||||
const codebuffsz = $1000
|
const codebuffsz = $1000
|
||||||
const pgjmp = 16
|
const pgjmp = 16
|
||||||
const changed = 1
|
const changed = 1
|
||||||
@ -3109,7 +3108,6 @@ def parse_value(rvalue)
|
|||||||
push_op(token, 0)
|
push_op(token, 0)
|
||||||
else
|
else
|
||||||
type = type | BPTR_TYPE
|
type = type | BPTR_TYPE
|
||||||
deref = deref + 1
|
|
||||||
fin
|
fin
|
||||||
break
|
break
|
||||||
is WPTR_TKN
|
is WPTR_TKN
|
||||||
@ -3117,7 +3115,6 @@ def parse_value(rvalue)
|
|||||||
push_op(token, 0)
|
push_op(token, 0)
|
||||||
else
|
else
|
||||||
type = type | WPTR_TYPE
|
type = type | WPTR_TYPE
|
||||||
deref = deref + 1
|
|
||||||
fin
|
fin
|
||||||
break
|
break
|
||||||
is AT_TKN
|
is AT_TKN
|
||||||
@ -3191,6 +3188,11 @@ def parse_value(rvalue)
|
|||||||
// Function call
|
// Function call
|
||||||
//
|
//
|
||||||
if emit_val
|
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
|
if ref_type & BPTR_TYPE; emit_lb
|
||||||
elsif ref_type & WPTR_TYPE; emit_lw; fin
|
elsif ref_type & WPTR_TYPE; emit_lw; fin
|
||||||
if lookahead <> CLOSE_PAREN_TKN
|
if lookahead <> CLOSE_PAREN_TKN
|
||||||
@ -3247,6 +3249,14 @@ def parse_value(rvalue)
|
|||||||
ref_offset = 0
|
ref_offset = 0
|
||||||
fin
|
fin
|
||||||
emit_val = TRUE
|
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
|
fin
|
||||||
while parse_expr
|
while parse_expr
|
||||||
if token <> COMMA_TKN
|
if token <> COMMA_TKN
|
||||||
@ -3290,6 +3300,14 @@ def parse_value(rvalue)
|
|||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
emit_val = 1;
|
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
|
fin
|
||||||
if token == PTRB_TKN
|
if token == PTRB_TKN
|
||||||
ref_type = BPTR_TYPE
|
ref_type = BPTR_TYPE
|
||||||
@ -3338,24 +3356,21 @@ def parse_value(rvalue)
|
|||||||
ref_offset = 0
|
ref_offset = 0
|
||||||
emit_val = TRUE
|
emit_val = TRUE
|
||||||
fin
|
fin
|
||||||
else
|
fin
|
||||||
if ref_offset <> 0
|
|
||||||
emit_const(ref_offset)
|
|
||||||
emit_op($02)
|
|
||||||
ref_offset = 0
|
|
||||||
fin
|
|
||||||
fin
|
|
||||||
break
|
break
|
||||||
wend
|
wend
|
||||||
loop
|
loop
|
||||||
if emit_val
|
if emit_val
|
||||||
if rvalue
|
if ref_offset <> 0
|
||||||
if deref and ref_type & PTR_TYPE
|
emit_const(ref_offset)
|
||||||
if ref_type & BPTR_TYPE
|
emit_op($02)
|
||||||
emit_lb
|
ref_offset = 0
|
||||||
else
|
fin
|
||||||
emit_lw
|
if deref and ref_type & PTR_TYPE
|
||||||
fin
|
if ref_type & BPTR_TYPE
|
||||||
|
emit_lb
|
||||||
|
else
|
||||||
|
emit_lw
|
||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
else // emit_val
|
else // emit_val
|
||||||
@ -3389,16 +3404,35 @@ def parse_value(rvalue)
|
|||||||
else
|
else
|
||||||
if type & CONST_TYPE
|
if type & CONST_TYPE
|
||||||
emit_const(value)
|
emit_const(value)
|
||||||
elsif type & LOCAL_TYPE
|
elsif type & ADDR_TYPE
|
||||||
emit_localaddr(value + ref_offset)
|
if type & PTR_TYPE
|
||||||
else
|
if type & LOCAL_TYPE
|
||||||
emit_globaladdr(value, ref_offset)
|
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
|
fin
|
||||||
fin // emit_val
|
fin // emit_val
|
||||||
while optos < opsp
|
while optos < opsp
|
||||||
if !emit_unaryop(pop_op); return parse_err(@bad_op); fin
|
if !emit_unaryop(pop_op); return parse_err(@bad_op); fin
|
||||||
loop
|
loop
|
||||||
|
if type & PTR_TYPE
|
||||||
|
ref_type = type
|
||||||
|
fin
|
||||||
if !ref_type
|
if !ref_type
|
||||||
ref_type = WORD_TYPE
|
ref_type = WORD_TYPE
|
||||||
fin
|
fin
|
||||||
|
Loading…
x
Reference in New Issue
Block a user