static public void Updata(Control.States state, Control.Codes code, long ifun, Control.Registers rA, Control.Registers rB, long valC, long valP) { D_state = state; D_icode = code; D_ifun = ifun; D_rA = rA; D_rB = rB; D_valC = valC; D_valP = valP; }
static public void Updata(Control.States state, Control.Codes icode, long ifun, long valE, long valM, Control.Registers dstE, Control.Registers dstM) { W_state = state; W_icode = icode; W_ifun = ifun; W_valE = valE; W_valM = valM; W_dstE = dstE; W_dstM = dstM; }
static public void Updata(Control.States state, Control.Codes icode, long ifun, bool Cnd, long valE, long valA, Control.Registers dstE, Control.Registers dstM) { M_state = state; M_icode = icode; M_ifun = ifun; M_Cnd = Cnd; M_valE = valE; M_valA = valA; M_dstE = dstE; M_dstM = dstM; }
static public void Work() { // if (M_state == Control.States.SHLT || M_state == Control.States.SINS) { m_state = M_state; return; } m_Addr = 0; if (M_icode == Control.Codes.IRET || M_icode == Control.Codes.IPOPQ) { m_Addr = M_valA; } if (M_icode == Control.Codes.IMRMOVQ || M_icode == Control.Codes.IRMMOVQ || M_icode == Control.Codes.ICALL || M_icode == Control.Codes.IPUSHQ) { m_Addr = M_valE; } if ((m_Addr > MEMORY_LIMIT || m_Addr < 0) && (M_icode == Control.Codes.IRMMOVQ || M_icode == Control.Codes.ICALL || M_icode == Control.Codes.IPUSHQ || M_icode == Control.Codes.IMRMOVQ || M_icode == Control.Codes.IRET || M_icode == Control.Codes.IPOPQ)) { m_state = Control.States.SMEM; return; } if (M_icode == Control.Codes.IPOPQ) { int deb = 0; int nm = deb + 1; } m_valM = 0; if (M_icode == Control.Codes.IRMMOVQ || M_icode == Control.Codes.ICALL || M_icode == Control.Codes.IPUSHQ) { long nm = M_valA; for (int i = 0; i < 8; i++) { long x = nm % 256; mem[m_Addr + i] = (int)x; nm /= 256; } } if (M_icode == Control.Codes.IMRMOVQ || M_icode == Control.Codes.IRET || M_icode == Control.Codes.IPOPQ) { for (int i = 0; i < 8; i++) { long x = (mem[m_Addr + i]); x = x << (i * 8); m_valM |= x; } } m_ifun = M_ifun; m_dstM = M_dstM; m_dstE = M_dstE; m_state = M_state; m_icode = M_icode; m_valE = M_valE; }
static public void Updata(Control.States state, Control.Codes icode, long ifun, long valC, long valA, long valB, Control.Registers dstE, Control.Registers dstM, Control.Registers srcA, Control.Registers srcB) { E_state = state; E_icode = icode; E_ifun = ifun; E_valC = valC; E_valA = valA; E_valB = valB; E_dstE = dstE; E_dstM = dstM; E_srcA = srcA; E_srcB = srcB; }
static public long Fwd(Control.Registers src, long rval) { if (src == Excute.Show_e_dstE()) { return(Excute.Show_e_valE()); } if (src == Memory.Show_M_dstM()) { return(Memory.Show_m_valM()); } if (src == Memory.Show_M_dstE()) { return(Memory.Show_M_valE()); } if (src == Write_back.Show_W_dstM()) { return(Write_back.Show_W_valM()); } if (src == Write_back.Show_W_dstE()) { return(Write_back.Show_W_valE()); } return(rval); }
static string Get_Reg(Control.Registers rg) { return(reg_name[(long)rg]); }
static public void Work() { long r0 = 0, r1 = 0; long valC = 0; f_PC = SelectPC(); Read_b(ref r0, ref r1); f_icode = (Control.Codes)r0; f_ifun = r1; r0 = r1 = 15; f_state = Control.States.SAOK; switch (f_icode) { case Control.Codes.IHALT: f_state = Control.States.SHLT; break; case Control.Codes.INOP: break; case Control.Codes.IRRMOVQ: Read_b(ref r0, ref r1); break; case Control.Codes.IIRMOVQ: Read_b(ref r0, ref r1); Read_d(ref valC); break; case Control.Codes.IRMMOVQ: Read_b(ref r0, ref r1); Read_d(ref valC); break; case Control.Codes.IMRMOVQ: Read_b(ref r0, ref r1); Read_d(ref valC); break; case Control.Codes.IOPQ: Read_b(ref r0, ref r1); break; case Control.Codes.IJXX: Read_d(ref valC); break; case Control.Codes.ICALL: Read_d(ref valC); break; case Control.Codes.IRET: break; case Control.Codes.IPUSHQ: Read_b(ref r0, ref r1); break; case Control.Codes.IPOPQ: Read_b(ref r0, ref r1); break; case Control.Codes.IIOPQ: Read_b(ref r0, ref r1); Read_d(ref valC); break; default: f_state = Control.States.SINS; f_icode = Control.Codes.IHALT; f_ifun = 0; break; } f_rA = (Control.Registers)r0; f_rB = (Control.Registers)r1; f_valC = valC; f_valP = f_PC; f_predPC = PredPC(); if (f_icode != Control.Codes.IOPQ && f_icode != Control.Codes.IJXX && f_icode != Control.Codes.IRRMOVQ && f_icode != Control.Codes.IIOPQ) { if (f_ifun != 0) { f_state = Control.States.SINS; } } else { if ((f_icode == Control.Codes.IOPQ || f_icode == Control.Codes.IIOPQ) && f_ifun > 3) { f_state = Control.States.SINS; } else if (f_ifun > 6) { f_state = Control.States.SINS; } } if ((f_icode == Control.Codes.IRRMOVQ || f_icode == Control.Codes.IRMMOVQ || f_icode == Control.Codes.IMRMOVQ || f_icode == Control.Codes.IOPQ) && (f_rA == Control.Registers.RNONE || f_rB == Control.Registers.RNONE)) { f_state = Control.States.SINS; } if ((f_icode == Control.Codes.IIRMOVQ || f_icode == Control.Codes.IIOPQ) && (f_rA != Control.Registers.RNONE || f_rB == Control.Registers.RNONE)) { f_state = Control.States.SINS; } if ((f_icode == Control.Codes.IPUSHQ || f_icode == Control.Codes.IPOPQ) && (f_rA == Control.Registers.RNONE || f_rB != Control.Registers.RNONE)) { f_state = Control.States.SINS; } }