Skip to content

[Enhancement] Label substitution within .REPEAT #670

@Ramsis-SNES

Description

@Ramsis-SNES

Hi again,

I've been trying to use label substitution within a .REPEAT as outlined in chapter 4.8 of the documentation, where it states:

It’s possible to substitute definition’s name with its value inside a
label.

Here’s an example:

.REPEAT 10 INDEX COUNT
Label_{COUNT}: ; -> Label_0, Label_1, Label_2...
.DW Label_{COUNT}
.ENDR

Now, unfortunately I'm having trouble getting the labels I want (text pointers, in this case). I have multiple pointer blocks and, upon checking them, I realized it creates the same pointer values for all blocks, which leads me to believe that the INDEX, named COUNT in the above example, always starts at zero, even if I do, say, .REDEFINE COUNT = 1024 right before another pointer block.

It would be very, very handy if we could define our own starting value for the index, e.g.

.REPEAT 500 INDEX COUNT START 500
Label_{COUNT}:                      ; -> Label_500..Label_999
.ENDR

Or, if we wanted to get really fancy, even adding STEP like in .ENUMs:

.REPEAT 500 INDEX COUNT START 1000 STEP 2
Label_{COUNT}:                      ; -> Label_1000, Label_1002 ... Label_1996, Label_1998
.ENDR

And, if that weren't enough already, maybe even allow DESC as well ... :D

.REPEAT 100 INDEX COUNT DESC START 300 STEP 3
Label_{COUNT}:                      ; -> Label_297, Label_294 ... Label_3, Label_0
.ENDR

Thanks for considering this, but no worries if it's not feasible/too much work, you've already been doing so much for us all anyway :D 👍

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