...
{
int *r1, *r2;
r1 = GetCorrectRegister(first);
r2 = GetCorrectRegister(second);
switch ((OpCode)current.opcode)
{
case OpCode.ADDR:
r2 = r1 + r2;
break;
}
}
...
This is the obvious, easiest way to solve this problem. However, I'd prefer not to use an unsafe method if I can avoid it. Basically, I have a bunch of integers which represent registers. There are assembly instructions that take register mnemonics as arguments. I'd prefer not to have the logic to determine which variable to assign to in each branch of the switch statement or make some sort of kludgey GetRegisterValue(mnemonic) and SetRegisterValue(mnemonic) functions. Is there some C#y way to do something similar?