Here's the deal about doing this. You want to emulate the registers in a uP. To do this, you need to tie the register identification to a variable that represents the register contents. You also need to tie an instruction mnemonic to a function that performs the instruction.

Since register mnemonics vary from chip to chip, the best way is to define a list of register names in such a way that finding the name in the list returns an index into a set of register variables (or possibly a pointer).

Similarly, with the opcode mnemonics. Consider a simple implementation. Operations (opcodes) may have zero, one, or two operands. Operands may be register IDs, immediate values, direct memory addresses (other variable names), or indirect memory addresses (pointers to other variable names).

Finding a mnemonic in a list would return (or imply) information regarding the number of operands, and how to use them. One then simply calls the appropriate function, much as one would do in a calculator implementation. Determining the appropriate function could be done in a number of ways. A switch or if construct related to the index of the mnemonic could be used, or the mnemonic-search could return a function pointer.

These operations could be performed using an array or a vector or a map. The information contained could be as simple as an index value, or as complex as a class or struct which contains all the information necessary for a particular mnemonic instruction. The class or struct could even possess information that would specify the machine code to be emitted.

The purpose of this post is to encourage you to thoroughly think about and design your application. When that is firmly fixed, in your mind and on paper, then you can sit down and translate it into the kind of code you feel is most appropriate.