zasm: allow duplicate const definition
This will allow interesting override scenarios, adding flexibility.
This commit is contained in:
parent
ffa28195b1
commit
c2d84563dd
@ -116,6 +116,10 @@ allowed. An included file cannot have an `#inc` directive.
|
|||||||
expression written as the second parameter. Example:
|
expression written as the second parameter. Example:
|
||||||
`.equ foo 0x42+'A'`
|
`.equ foo 0x42+'A'`
|
||||||
|
|
||||||
|
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
|
||||||
offset. For example, if we want to place an instruction exactly at
|
offset. For example, if we want to place an instruction exactly at
|
||||||
|
@ -149,6 +149,13 @@ handleEQU:
|
|||||||
ld hl, DIREC_SCRATCHPAD
|
ld hl, DIREC_SCRATCHPAD
|
||||||
push ix \ pop de
|
push ix \ pop de
|
||||||
call symRegisterConst ; A and Z set
|
call symRegisterConst ; A and Z set
|
||||||
|
jr z, .end ; success
|
||||||
|
; register ended up in error. We need to figure which error. If it's
|
||||||
|
; a duplicate error, we ignore it and return success because, as per
|
||||||
|
; ".equ" policy, it's fine to define the same const twice. The first
|
||||||
|
; value has precedence.
|
||||||
|
cp ERR_DUPSYM
|
||||||
|
; whatever the value of Z, it's the good one, return
|
||||||
jr .end
|
jr .end
|
||||||
.badfmt:
|
.badfmt:
|
||||||
ld a, ERR_BAD_FMT
|
ld a, ERR_BAD_FMT
|
||||||
|
Binary file not shown.
@ -55,5 +55,5 @@ chkerr "#inc foo" 19
|
|||||||
chkerr "ld a, 0x100" 20
|
chkerr "ld a, 0x100" 20
|
||||||
chkerr ".db 0x100" 20
|
chkerr ".db 0x100" 20
|
||||||
chkerr "#inc \"doesnotexist\"" 21
|
chkerr "#inc \"doesnotexist\"" 21
|
||||||
chkerr ".equ foo 42 \\ .equ foo 42" 22
|
chkerr "foo:\\foo:" 22
|
||||||
chkoom
|
chkoom
|
||||||
|
5
tools/tests/zasm/test7.asm
Normal file
5
tools/tests/zasm/test7.asm
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
; It's fine to declare the same constant twice. Only the first value is
|
||||||
|
; kept
|
||||||
|
.equ FOO 42
|
||||||
|
.equ FOO 22
|
||||||
|
ld a, FOO
|
1
tools/tests/zasm/test7.asm.expected
Normal file
1
tools/tests/zasm/test7.asm.expected
Normal file
@ -0,0 +1 @@
|
|||||||
|
>*
|
Loading…
Reference in New Issue
Block a user