mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 20:30:56 +11:00
Compare commits
2 Commits
7cf3ed38da
...
79e04189b0
Author | SHA1 | Date | |
---|---|---|---|
|
79e04189b0 | ||
|
6e714875dc |
@ -76,6 +76,12 @@ forward-reference labels.
|
|||||||
|
|
||||||
However, they *cannot* forward-reference other constants.
|
However, they *cannot* forward-reference other constants.
|
||||||
|
|
||||||
|
When defining a constant, if the symbol specified has already been defined, no
|
||||||
|
error occur and the first value defined stays intact. This allows for "user
|
||||||
|
override" of programs.
|
||||||
|
|
||||||
|
It's also important to note that constants always override labels, regardless
|
||||||
|
of declaration order.
|
||||||
|
|
||||||
## Expressions
|
## Expressions
|
||||||
|
|
||||||
@ -119,11 +125,7 @@ allowed. An included file cannot have an `.inc` directive.
|
|||||||
|
|
||||||
**.equ**: Binds a symbol named after the first parameter to the value of the
|
**.equ**: Binds a symbol named after the first parameter to the value of the
|
||||||
expression written as the second parameter. Example:
|
expression written as the second parameter. Example:
|
||||||
`.equ foo 0x42+'A'`
|
`.equ foo 0x42+'A'`. See "Constants" above.
|
||||||
|
|
||||||
If the symbol specified has already been defined, no error occur and
|
|
||||||
the first value defined stays intact. This allows for "user override"
|
|
||||||
of programs.
|
|
||||||
|
|
||||||
**.fill**: Outputs the number of null bytes specified by its argument, an
|
**.fill**: Outputs the number of null bytes specified by its argument, an
|
||||||
expression. Often used with `$` to fill our binary up to a certain
|
expression. Often used with `$` to fill our binary up to a certain
|
||||||
|
@ -219,13 +219,13 @@ symFindVal:
|
|||||||
push ix
|
push ix
|
||||||
call symIsLabelLocal
|
call symIsLabelLocal
|
||||||
jr z, .local
|
jr z, .local
|
||||||
; global. Let's try labels first, then consts
|
; global. Let's try consts first, then symbols
|
||||||
push hl ; --> lvl 1. we'll need it again if not found.
|
push hl ; --> lvl 1. we'll need it again if not found.
|
||||||
ld ix, SYM_GLOBAL_REGISTRY
|
ld ix, SYM_CONST_REGISTRY
|
||||||
call _symFind
|
call _symFind
|
||||||
pop hl ; <-- lvl 1
|
pop hl ; <-- lvl 1
|
||||||
jr z, .found
|
jr z, .found
|
||||||
ld ix, SYM_CONST_REGISTRY
|
ld ix, SYM_GLOBAL_REGISTRY
|
||||||
call _symFind
|
call _symFind
|
||||||
jr nz, .end
|
jr nz, .end
|
||||||
.found:
|
.found:
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -2,8 +2,11 @@ jp test
|
|||||||
|
|
||||||
.inc "core.asm"
|
.inc "core.asm"
|
||||||
|
|
||||||
|
dummyLabel:
|
||||||
testNum: .db 1
|
testNum: .db 1
|
||||||
|
|
||||||
|
.equ dummyLabel 0x42
|
||||||
|
|
||||||
test:
|
test:
|
||||||
ld hl, 0xffff
|
ld hl, 0xffff
|
||||||
ld sp, hl
|
ld sp, hl
|
||||||
@ -30,6 +33,13 @@ test:
|
|||||||
jp p, fail ; negative
|
jp p, fail ; negative
|
||||||
call nexttest
|
call nexttest
|
||||||
|
|
||||||
|
; Test that .equ can override label
|
||||||
|
ld a, 0x42
|
||||||
|
ld hl, dummyLabel
|
||||||
|
cp l
|
||||||
|
jp nz, fail
|
||||||
|
call nexttest
|
||||||
|
|
||||||
; *** cpHLDE ***
|
; *** cpHLDE ***
|
||||||
ld hl, 0x42
|
ld hl, 0x42
|
||||||
ld de, 0x42
|
ld de, 0x42
|
||||||
|
Loading…
Reference in New Issue
Block a user