Code: Select all
ldi_3:
LDI
ldi_2:
LDI
ldi_1:
LDI
RET
ldi_table:
DW ldi_1
DW ldi_2
DW ldi_3
Code: Select all
%for i=3 to 1
ldi_{i}:
LDI
%next i
RET
ldi_table:
%for i=1 to 3
DW ldi_{i}
%next i
TIA
Code: Select all
ldi_3:
LDI
ldi_2:
LDI
ldi_1:
LDI
RET
ldi_table:
DW ldi_1
DW ldi_2
DW ldi_3
Code: Select all
%for i=3 to 1
ldi_{i}:
LDI
%next i
RET
ldi_table:
%for i=1 to 3
DW ldi_{i}
%next i
Code: Select all
ERROR: Unexpected '##' used as instruction
ERROR: Unexpected '&' used as instruction
Code: Select all
MACRO DEFLABEL_LDI, _idx
LDI_##_idx EQU $
ENDM
MACRO DWLABEL_LDI, _idx
DEFW LDI_##_idx
ENDM
IRP _idx, 3, 2, 1
DEFLABEL_LDI _idx
ldi
ENDM
ret
IRP _idx, 1, 2, 3
DWLABEL_LDI _idx
ENDM
Code: Select all
IDXLABEL MACRO prefix, name, suffix
prefix ## name ## suffix:
ENDM
DW_IDXLABEL MACRO prefix, name, suffix
DW prefix ## name ## suffix
ENDM
main_start EQU $6000
ORG main_start
main:
LD HL, $5800
LD DE, $5820
IRP count, 3
IDXLABEL ldi_, count, _idx
LDI
ENDM
RET
ldi_table:
IRP count, 3
DW_IDXLABEL ldi_, count, _idx
ENDM
END main_start
Code: Select all
pasmo -1 --tapbas test.asm test.bin
Code: Select all
ldi_3:
LDI
ldi_2:
LDI
ldi_1:
LDI
RET
ldi_table:
DW ldi_1
DW ldi_2
DW ldi_3
Code: Select all
address_1:
instructions...
address_2:
instructions...
address_3:
instructions...
table:
DW address_1
DW address_2
DW address_3
If you had first read the answers already given, then you may have had a better idea of the problem.
Is that right? As I'm reading it for how IRP (rather than REPT) works, shouldn't the syntax be???:
I haven't tried that, but according to the documentation, I think you would get 6 repetitions (1+2+3 = 6).