- if (reg == "a0") {
- text[cursor] = Script::CODE_MOVE_A0;
- ++cursor;
- ReadScriptAddress(**i, text + cursor);
- cursor += sizeof(void *);
- } else if (reg == "a1") {
- text[cursor] = Script::CODE_MOVE_A1;
- ++cursor;
- ReadScriptAddress(**i, text + cursor);
- cursor += sizeof(void *);
- } else if (reg == "i0") {
- text[cursor] = Script::CODE_MOVE_I0;
- ++cursor;
- ReadScriptInteger(**i, text + cursor);
- cursor += sizeof(int);
- } else if (reg == "i1") {
- text[cursor] = Script::CODE_MOVE_I1;
- ++cursor;
- ReadScriptInteger(**i, text + cursor);
- cursor += sizeof(int);
- } else if (reg == "v0") {
- text[cursor] = Script::CODE_MOVE_V0;
- ++cursor;
- ReadScriptVector(**i, text + cursor);
- cursor += sizeof(Vector<int>);
- } else if (reg == "v1") {
- text[cursor] = Script::CODE_MOVE_V1;
- ++cursor;
- ReadScriptVector(**i, text + cursor);
- cursor += sizeof(Vector<int>);
+
+ if ((*i)->GetType() == ScriptToken::REGISTER) {
+ string reg2((*i)->RegisterName());
+ if (reg[0] != reg2[0]) {
+ throw Error("mixed-type commands not allowed");
+ }
+ int reg2num(reg[1] - '0');
+ if (reg2num < 0 || reg2num > 6) {
+ throw Error("invalid register " + reg2);
+ }
+ code.reg2 = reg2num;