private void END(byte[] Arg1, byte[] Arg2) { PEND = (Register)PC.ToInt(); PC = (Register)PSTR.ToInt(); }
private void GOTO(byte[] Arg1, byte[] Arg2) { //================================== //GOTO Arg1 //---------------------------------- //Supports all valid data types //Copies value from Arg1 into PC //================================== byte[] data = new byte[2]; data[0] = 0x00; data[1] = 0x00; byte Arg1Type = Arg1[0]; if (Arg1Type == 0x00 || Arg1Type == 0x10 || Arg1Type == 0x20 || Arg1Type == 0x01 || Arg1Type == 0x02 || Arg1Type == 0x12 || Arg1Type == 0x22 || Arg1Type == 0x03 || Arg1Type == 0x13 || Arg1Type == 0x23 || Arg1Type == 0x04 || Arg1Type == 0x14 || Arg1Type == 0x24 || Arg1Type == 0x05 || Arg1Type == 0x15 || Arg1Type == 0x25) { data = getDataFromParameter(Arg1); } else { throw new Exception("Unsupported data type"); } PC = (Register)data; }
private void START(byte[] Arg1, byte[] Arg2) { PSTR = (Register)PC.ToInt(); }
private void setRegisterFromID(byte id, byte[] value, int mode) { //Mode: // 0: 16-bit word // 1: Lower byte, value[1] // 2: Upper byte, value[0] switch (id) { case 0x00: if (mode == 0) { PC = (Register)value; } else if (mode == 1) { PC.LowerByte = value[1]; } else if (mode == 2) { PC.UpperByte = value[1]; } break; case 0x01: if (mode == 0) { STAT = (StatusRegister)value; } else if (mode == 1) { STAT.LowerByte = value[1]; } else if (mode == 2) { STAT.UpperByte = value[1]; } break; case 0x02: if (mode == 0) { SUBR = (Register)value; } else if (mode == 1) { SUBR.LowerByte = value[1]; } else if (mode == 2) { SUBR.UpperByte = value[1]; } break; case 0x03: if (mode == 0) { PSTR = (Register)value; } else if (mode == 1) { PSTR.LowerByte = value[1]; } else if (mode == 2) { PSTR.UpperByte = value[1]; } break; case 0x04: if (mode == 0) { PEND = (Register)value; } else if (mode == 1) { PEND.LowerByte = value[1]; } else if (mode == 2) { PEND.UpperByte = value[1]; } break; case 0x05: throw new Exception("\nCannot store data in RAND\n"); //break; case 0x06: if (mode == 0) { RREF = (Register)value; } else if (mode == 1) { RREF.LowerByte = value[1]; } else if (mode == 2) { RREF.UpperByte = value[1]; } break; case 0x07: if (mode == 0) { PAGE = (Register)value; } else if (mode == 1) { PAGE.LowerByte = value[1]; } else if (mode == 2) { PAGE.UpperByte = value[1]; } break; case 0x08: if (mode == 0) { MEMS = (Register)value; } else if (mode == 1) { MEMS.LowerByte = value[1]; } else if (mode == 2) { MEMS.UpperByte = value[1]; } break; case 0x09: if (mode == 0) { PEEK = (Register)value; } else if (mode == 1) { PEEK.LowerByte = value[1]; } else if (mode == 2) { PEEK.UpperByte = value[1]; } break; case 0xF0: if (mode == 0) { USR0 = (Register)value; } else if (mode == 1) { USR0.LowerByte = value[1]; } else if (mode == 2) { USR0.UpperByte = value[1]; } break; case 0xF1: if (mode == 0) { USR1 = (Register)value; } else if (mode == 1) { USR1.LowerByte = value[1]; } else if (mode == 2) { USR1.UpperByte = value[1]; } break; case 0xF2: if (mode == 0) { USR2 = (Register)value; } else if (mode == 1) { USR2.LowerByte = value[1]; } else if (mode == 2) { USR2.UpperByte = value[1]; } break; case 0xF3: if (mode == 0) { USR3 = (Register)value; } else if (mode == 1) { USR3.LowerByte = value[1]; } else if (mode == 2) { USR3.UpperByte = value[1]; } break; case 0xF4: if (mode == 0) { USR4 = (Register)value; } else if (mode == 1) { USR4.LowerByte = value[1]; } else if (mode == 2) { USR4.UpperByte = value[1]; } break; case 0xF5: if (mode == 0) { USR5 = (Register)value; } else if (mode == 1) { USR5.LowerByte = value[1]; } else if (mode == 2) { USR5.UpperByte = value[1]; } break; case 0xF6: if (mode == 0) { USR6 = (Register)value; } else if (mode == 1) { USR6.LowerByte = value[1]; } else if (mode == 2) { USR6.UpperByte = value[1]; } break; case 0xF7: if (mode == 0) { USR7 = (Register)value; } else if (mode == 1) { USR7.LowerByte = value[1]; } else if (mode == 2) { USR7.UpperByte = value[1]; } break; case 0xF8: if (mode == 0) { USR8 = (Register)value; } else if (mode == 1) { USR8.LowerByte = value[1]; } else if (mode == 2) { USR8.UpperByte = value[1]; } break; case 0xF9: if (mode == 0) { USR9 = (Register)value; } else if (mode == 1) { USR9.LowerByte = value[1]; } else if (mode == 2) { USR9.UpperByte = value[1]; } break; case 0xFA: if (mode == 0) { USRA = (Register)value; } else if (mode == 1) { USRA.LowerByte = value[1]; } else if (mode == 2) { USRA.UpperByte = value[1]; } break; case 0xFB: if (mode == 0) { USRB = (Register)value; } else if (mode == 1) { USRB.LowerByte = value[1]; } else if (mode == 2) { USRB.UpperByte = value[1]; } break; case 0xFC: if (mode == 0) { USRC = (Register)value; } else if (mode == 1) { USRC.LowerByte = value[1]; } else if (mode == 2) { USRC.UpperByte = value[1]; } break; case 0xFD: if (mode == 0) { USRD = (Register)value; } else if (mode == 1) { USRD.LowerByte = value[1]; } else if (mode == 2) { USRD.UpperByte = value[1]; } break; case 0xFE: if (mode == 0) { USRE = (Register)value; } else if (mode == 1) { USRE.LowerByte = value[1]; } else if (mode == 2) { USRE.UpperByte = value[1]; } break; case 0xFF: if (mode == 0) { USRF = (Register)value; } else if (mode == 1) { USRF.LowerByte = value[1]; } else if (mode == 2) { USRF.UpperByte = value[1]; } break; default: break; } }
private void RTRN(byte[] Arg1, byte[] Arg2) { //================================== //RTRN //---------------------------------- //Sets PC to the address after SUBR //================================== PC = (Register)(SUBR.ToInt() + 1); }
private void JMPZ(byte[] Arg1, byte[] Arg2) { //================================== //JMPZ Arg1 //---------------------------------- //Supports all valid data types //If the Z flag is set, PC is set to Arg1 //================================== byte[] data = new byte[2]; data[0] = 0x00; data[1] = 0x00; byte Arg1Type = Arg1[0]; if (Arg1Type == 0x00 || Arg1Type == 0x10 || Arg1Type == 0x20 || Arg1Type == 0x01 || Arg1Type == 0x02 || Arg1Type == 0x12 || Arg1Type == 0x22 || Arg1Type == 0x03 || Arg1Type == 0x13 || Arg1Type == 0x23 || Arg1Type == 0x04 || Arg1Type == 0x14 || Arg1Type == 0x24 || Arg1Type == 0x05 || Arg1Type == 0x15 || Arg1Type == 0x25) { data = getDataFromParameter(Arg1); } else { throw new Exception("Unsupported data type"); } if (STAT.Z) { PC = (Register)data; } }
private void GSUB(byte[] Arg1, byte[] Arg2) { //================================== //GSUB Arg1 //---------------------------------- //Supports all valid data types //Stores PC in SUBR, sets PC to Arg1 //================================== byte[] data = new byte[2]; data[0] = 0x00; data[1] = 0x00; byte Arg1Type = Arg1[0]; if (Arg1Type == 0x00 || Arg1Type == 0x10 || Arg1Type == 0x20 || Arg1Type == 0x01 || Arg1Type == 0x02 || Arg1Type == 0x12 || Arg1Type == 0x22 || Arg1Type == 0x03 || Arg1Type == 0x13 || Arg1Type == 0x23 || Arg1Type == 0x04 || Arg1Type == 0x14 || Arg1Type == 0x24 || Arg1Type == 0x05 || Arg1Type == 0x15 || Arg1Type == 0x25) { data = getDataFromParameter(Arg1); } else { throw new Exception("Unsupported data type"); } UInt16 arg1Word = (UInt16)(data[0] << 8 | data[1]); SUBR = (Register)PC.ToInt(); PC = (Register)arg1Word; }