mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-30 20:38:05 +11:00
zasm: bump global symbol limit to 0x200
This commit is contained in:
parent
44abc79850
commit
3b1ef2b9af
@ -233,7 +233,7 @@ parseNumberOrSymbol:
|
|||||||
call symSelect
|
call symSelect
|
||||||
call symFind
|
call symFind
|
||||||
ret nz ; not found
|
ret nz ; not found
|
||||||
; Found! index in A, let's fetch value
|
; Found! let's fetch value
|
||||||
push de
|
push de
|
||||||
call symGetVal
|
call symGetVal
|
||||||
; value in DE. We need it in IX
|
; value in DE. We need it in IX
|
||||||
|
@ -16,12 +16,14 @@
|
|||||||
; Symbol registry buffer is full
|
; Symbol registry buffer is full
|
||||||
.equ SYM_ERR_FULLBUF 0x02
|
.equ SYM_ERR_FULLBUF 0x02
|
||||||
|
|
||||||
; Maximum number of symbols we can have in the registry
|
; Maximum number of symbols we can have in the global registry
|
||||||
.equ SYM_MAXCOUNT 0x100
|
.equ SYM_MAXCOUNT 0x200
|
||||||
|
; Maximum number of symbols we can have in the local registry
|
||||||
|
.equ SYM_LOC_MAXCOUNT 0x40
|
||||||
|
|
||||||
; Size of the symbol name buffer size. This is a pool. There is no maximum name
|
; Size of the symbol name buffer size. This is a pool. There is no maximum name
|
||||||
; length for a single symbol, just a maximum size for the whole pool.
|
; length for a single symbol, just a maximum size for the whole pool.
|
||||||
.equ SYM_BUFSIZE 0x1000
|
.equ SYM_BUFSIZE 0x2000
|
||||||
|
|
||||||
; Size of the names buffer for the local context registry
|
; Size of the names buffer for the local context registry
|
||||||
.equ SYM_LOC_BUFSIZE 0x200
|
.equ SYM_LOC_BUFSIZE 0x200
|
||||||
@ -37,14 +39,16 @@
|
|||||||
|
|
||||||
; Registry for local labels. Wiped out after each context change.
|
; Registry for local labels. Wiped out after each context change.
|
||||||
.equ SYM_LOC_VALUES SYM_NAMES+SYM_BUFSIZE
|
.equ SYM_LOC_VALUES SYM_NAMES+SYM_BUFSIZE
|
||||||
.equ SYM_LOC_NAMES SYM_LOC_VALUES+SYM_MAXCOUNT*2
|
.equ SYM_LOC_NAMES SYM_LOC_VALUES+SYM_LOC_MAXCOUNT*2
|
||||||
|
|
||||||
; Pointer to the currently selected registry
|
; Pointer to the currently selected registry
|
||||||
.equ SYM_CTX_NAMES SYM_LOC_NAMES+SYM_LOC_BUFSIZE
|
.equ SYM_CTX_NAMES SYM_LOC_NAMES+SYM_LOC_BUFSIZE
|
||||||
.equ SYM_CTX_NAMESEND SYM_CTX_NAMES+2
|
.equ SYM_CTX_NAMESEND SYM_CTX_NAMES+2
|
||||||
.equ SYM_CTX_VALUES SYM_CTX_NAMESEND+2
|
.equ SYM_CTX_VALUES SYM_CTX_NAMESEND+2
|
||||||
|
; Pointer, in (SYM_CTX_VALUES), to the result of the last symFind
|
||||||
|
.equ SYM_CTX_PTR SYM_CTX_VALUES+2
|
||||||
|
|
||||||
.equ SYM_RAMEND SYM_CTX_VALUES+2
|
.equ SYM_RAMEND SYM_CTX_PTR+2
|
||||||
|
|
||||||
; *** Code ***
|
; *** Code ***
|
||||||
|
|
||||||
@ -113,6 +117,7 @@ symIsLabelLocal:
|
|||||||
; If we're within bounds, Z is set, otherwise unset.
|
; If we're within bounds, Z is set, otherwise unset.
|
||||||
symNamesEnd:
|
symNamesEnd:
|
||||||
push ix
|
push ix
|
||||||
|
push bc
|
||||||
|
|
||||||
ld ix, (SYM_CTX_VALUES)
|
ld ix, (SYM_CTX_VALUES)
|
||||||
ld hl, (SYM_CTX_NAMES)
|
ld hl, (SYM_CTX_NAMES)
|
||||||
@ -122,16 +127,26 @@ symNamesEnd:
|
|||||||
jr nz, .success ; We've reached the end of the chain.
|
jr nz, .success ; We've reached the end of the chain.
|
||||||
inc ix
|
inc ix
|
||||||
inc ix
|
inc ix
|
||||||
; Are we out of bounds?
|
; Are we out of bounds name-wise?
|
||||||
call cpHLDE
|
call cpHLDE
|
||||||
jr c, .loop ; HL < DE
|
jr nc, .outOfBounds ; HL >= DE
|
||||||
; out of bounds
|
; are we out of bounds value-wise? check if IX == (SYM_CTX_NAMES)
|
||||||
|
; Is is assumed that values are placed right before names
|
||||||
|
push hl
|
||||||
|
push ix \ pop bc
|
||||||
|
ld hl, (SYM_CTX_NAMES)
|
||||||
|
sbc hl, bc
|
||||||
|
pop hl
|
||||||
|
jr z, .outOfBounds ; IX == (SYM_CTX_NAMES)
|
||||||
|
jr .loop
|
||||||
|
.outOfBounds:
|
||||||
call unsetZ
|
call unsetZ
|
||||||
jr .end
|
jr .end
|
||||||
.success:
|
.success:
|
||||||
push ix \ pop de ; our values pos goes in DE
|
push ix \ pop de ; our values pos goes in DE
|
||||||
cp a ; ensure Z
|
cp a ; ensure Z
|
||||||
.end:
|
.end:
|
||||||
|
pop bc
|
||||||
pop ix
|
pop ix
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -197,16 +212,17 @@ symSelect:
|
|||||||
jp z, symSelectLocalRegistry
|
jp z, symSelectLocalRegistry
|
||||||
jp symSelectGlobalRegistry
|
jp symSelectGlobalRegistry
|
||||||
|
|
||||||
; Find name (HL) in (SYM_CTX_NAMES) and returns matching index in A.
|
; Find name (HL) in (SYM_CTX_NAMES) and make (SYM_CTX_PTR) point to the
|
||||||
|
; corresponding entry in (SYM_CTX_VALUES).
|
||||||
; If we find something, Z is set, otherwise unset.
|
; If we find something, Z is set, otherwise unset.
|
||||||
symFind:
|
symFind:
|
||||||
|
push ix
|
||||||
push hl
|
push hl
|
||||||
push bc
|
|
||||||
push de
|
push de
|
||||||
|
|
||||||
ex de, hl ; it's easier if HL is haystack and DE is
|
ex de, hl ; it's easier if HL is haystack and DE is
|
||||||
; needle.
|
; needle.
|
||||||
ld b, 0
|
ld ix, (SYM_CTX_VALUES)
|
||||||
ld hl, (SYM_CTX_NAMES)
|
ld hl, (SYM_CTX_NAMES)
|
||||||
.loop:
|
.loop:
|
||||||
call strcmp
|
call strcmp
|
||||||
@ -214,31 +230,23 @@ symFind:
|
|||||||
; ok, next!
|
; ok, next!
|
||||||
call _symNext
|
call _symNext
|
||||||
jr nz, .nomatch ; end of the chain, nothing found
|
jr nz, .nomatch ; end of the chain, nothing found
|
||||||
djnz .loop
|
inc ix
|
||||||
|
inc ix
|
||||||
|
jr .loop
|
||||||
; exhausted djnz? no match
|
; exhausted djnz? no match
|
||||||
.nomatch:
|
.nomatch:
|
||||||
call unsetZ
|
call unsetZ
|
||||||
jr .end
|
jr .end
|
||||||
.match:
|
.match:
|
||||||
; Our index is 0 - B (if B is, for example 0xfd, A is 0x3)
|
ld (SYM_CTX_PTR), ix
|
||||||
xor a
|
|
||||||
sub b
|
|
||||||
cp a ; ensure Z
|
cp a ; ensure Z
|
||||||
.end:
|
.end:
|
||||||
pop de
|
pop de
|
||||||
pop bc
|
|
||||||
pop hl
|
pop hl
|
||||||
|
pop ix
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Return value associated with symbol index A into DE
|
; Return value that (SYM_CTX_PTR) is pointing at in DE.
|
||||||
symGetVal:
|
symGetVal:
|
||||||
; our index is in A. Let's fetch the proper value
|
ld de, (SYM_CTX_PTR)
|
||||||
push hl
|
jp intoDE
|
||||||
ld hl, (SYM_CTX_VALUES)
|
|
||||||
call addHL
|
|
||||||
call addHL ; twice because our values are words
|
|
||||||
ld e, (hl)
|
|
||||||
inc hl
|
|
||||||
ld d, (hl)
|
|
||||||
pop hl
|
|
||||||
ret
|
|
||||||
|
@ -28,13 +28,8 @@ test:
|
|||||||
jp nz, fail
|
jp nz, fail
|
||||||
|
|
||||||
ld hl, sFOO
|
ld hl, sFOO
|
||||||
call symFind
|
call symFind ; don't match FOOBAR
|
||||||
jp nz, fail
|
jp nz, fail
|
||||||
cp 1 ; don't match FOOBAR
|
|
||||||
jp nz, fail
|
|
||||||
call nexttest
|
|
||||||
|
|
||||||
ld a, 1 ; index of FOO
|
|
||||||
call symGetVal
|
call symGetVal
|
||||||
ld a, d
|
ld a, d
|
||||||
or a
|
or a
|
||||||
|
@ -25,4 +25,4 @@ label2: .dw 0x42
|
|||||||
rr e
|
rr e
|
||||||
rlc c
|
rlc c
|
||||||
cp '-'
|
cp '-'
|
||||||
sbc hl, bc
|
sbc hl, de
|
||||||
|
Loading…
Reference in New Issue
Block a user