Skip to content

for next with local symbol can fail #32

@stefandrissen

Description

@stefandrissen

I'll add more details as I dig further.

I have a source that has multiple for next loops using the same @channel symbol.

; block 3

@channel: equ for 6

    ; some repeated code
    call foo{@channel}

next @channel

; some other code

; block 4

@channel: equ for 6

    foo{@channel}: 
    ; more repeated code
    ret

next @channel

When using local symbols, a minus can be used to force pyz80 to look backwards instead of finding the nearest local symbol. When using a next I would expect that look backwards is implied.

But... in this source if I remove some lines of comment, one of the @channel loops manages to reach value 6 causing a failure:

pass  1 ...
pass  2 ...
src\furplayer.s:941 error: Error in expression otherEffects4_7Ch{@channel}: Undefined symbol otherEffects4_7Ch6
      ld (otherEffects4_7Ch{@channel}),a

When I restore a comment line all is well again:

 pass  1 ...
 pass  2 ...
 Finished

The for | next lines for @channel are:

  • 494 | 498
  • 858 | 862
  • 891 | 966 - contains ld (otherEffects4_7Ch{@channel}),a
  • 991 | 1797 - contains otherEffects4_7Ch{@channel}: defining the symbol

The number of lines between the 3rd and 4th block trigger the 3rd block iterating past its boundary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions