First of all, this is my very first question on assembly, and I am still at the very beginning of my (hopefully long) learning journey, so forgive me if some terms are completely wrong (I hope my question at least makes some sense).
I am using VASM assembler to build a Z80 program.
I have a subroutine that makes use of VASM's inline
/einline
directives to define local labels as explained in the docs.
The part of the code which gives me the error on compilation is the following:
PlayerSprY:
; player Y SPRITES' VERTICAL IN SAT
; Parameters: hl = SATY address
; Affects: a, hl, b
rept 4 ; repeat 4 times as player is 4 tiles tall
inline ; use local name space (VASM does not have local name space like WLA-DX)
ld b,3 ; counter 3 as player is tile wide
PlayerSprYLoop:
out (VDPData),a
inc hl
djnz PlayerSprYLoop ; decrease B and jump back if NonZero
add a,8 ; add 8 (since next row is 8 pixels below.)
einline ; end of local name space (http://eab.abime.net/showthread.php?t=88827)
endr ; end of rept
ret
And the error I get is:
error 75 in line 3 of "REPEAT:Hello World.asm:line 192": label <PlayerSprYLoop> redefined
included from line 192 of "Hello World.asm"
> PlayerSprYLoop:
I understand that PlayerSprYLoop
label is redefined 4 times due to rept 4
, but I thought that placing my definition within an inline
/einline
block would have prevented this error.
CodePudding user response:
I have already found out the answer.
In the same docs I pointed out, it reads
Local labels are preceded by ’.’ or terminated by ’$’. For the rest, any alphanumeric character including ’_’ is allowed. Local labels are valid between two global label definitions.
Therefore, this code compiles correctly (note that PlayerSprYLoop
became .PlayerSprYLoop
):
PlayerSprY:
; player Y SPRITES' VERTICAL IN SAT
; Parameters: hl = SATY address
; Affects: a, hl, b
rept 4 ; repeat 4 times as player is 4 tiles tall
inline ; use local name space (VASM does not have local name space like WLA-DX)
ld b,3 ; counter 3 as player is tile wide
.PlayerSprYLoop:
out (VDPData),a
inc hl
djnz .PlayerSprYLoop ; decrease B and jump back if NonZero
add a,8 ; add 8 (since next row is 8 pixels below.)
einline ; end of local name space (http://eab.abime.net/showthread.php?t=88827)
endr ; end of rept
ret