I have a list of opcodes declared like this:
enum OpCode {
PUSH = 0x01,
POP = 0x02,
DUP = 0x03,
//...etc (the list is too long to copy-paste it here and it wouldn't make a lot of sense)
}
What I want is to "automatically" (via macros):
- create an array of their string representations, like:
static const char *OpCodeStr[] = {"PUSH","POP","DUP",...};
- create an array of some labels (for dispatch) using the different enum values, like:
static void* dispatchTable[] = {&&PUSH_, &&POP_, &&DUP_, ...};
I believe it should be possible using C macros, but I still have not figured out how.
Any ideas?