I am fairly certain I have seen this in code before, but I am unable to find any references on how to do it. I do expect this to be compiler or assembler specific.
I want to define an function pointer array of (compile-time) fixed length for use as an interrupt vector table on an embedded device. Each handler will push its interrupt number before jumping to a common handler. Creating a macro for these simpler functions is straight forward:
.macro irq number
.global irq\number
irq\number:
pushd $\number
jmp irq_handler_common
.endm
These can then be defined manually like this:
irq 0
irq 1
irq 2
...
However, I would rather not clutter my ASM file by manually defining 256 of these. Thus, what I would like to do is use an for-loop like preprocessor/macro that would allow me to do something like this:
for i in 0 ... 255
irq i
Can this be done in using macros?