cpu.java

来自「熟悉非常简单CPU模拟器 1、将所给模拟器的源程序编译成执行程序。 2、运行并观」· Java 代码 · 共 3,404 行 · 第 1/5 页

JAVA
3,404
字号
                  controlUnit.repaint();
               }

               atBeginBreak = true;
            }

         }

      }

      if ( ! stallAnimationCounter )
      {

         if ( counter1 == 1 )
         {
            counter1 = 0;
            counter2 = 0;

            simulationStartNumber++;
         }
         else
         {
            counter1++;
         }

      }

   }
*/
// *************************** END NOP ******************************

// *************************** LDAC ******************************
/*
   public void LDAC()
   {

      if ( counter1 == 50 )
      {
         // ** LDAC5 ** End of AC <- DR
         dot1=287;
         dot2=512;

         theBox.AC = theBox.DR;
         theBox.ACint = theBox.DRint;
      }

      if(counter1==49)
      {

			dot1=250;
			dot2=512;

      }

		if(counter1==48)
		{

			dot1=207;
                        dot2=520;

                        counter2 = 2;

		}

		if(counter1==47)
		{

			dot1=170;
			dot2=520;

		}

		if(counter1==46)
		{

			dot1=149;
			dot2=520;

		}

		if(counter1==45)
		{

			dot1=149;
			dot2=632;

		}

		if(counter1==44)
		{

			dot1=547;
			dot2=632;

		}

		if(counter1==43)
		{

			dot1=547;
			dot2=272;

		}

		if(counter1==42)
		{

			dot1=527;
			dot2=272;

		}

		if(counter1==41)
		{

			dot1=480;
			dot2=272;

		}

      if ( counter1 == 40 )
      {
         mcu.setCLKEnabled( false );

         controlUnit.m18 = 0;

         m21 = 0;

         dot1=457;
         dot2=272;

         if ( ! skipAnimation )
         {
            mcu.canvasRepaint();
            controlUnit.repaint();
         }

      }

      if ( counter1 == 39 )
      {
         // ** LDAC5 **  AC <- DR

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "LDAC5";

            canCycleBreak = true;
            stallAnimationCounter = true;
         }
         else
         {
            mcu.executeCycle();

            if ( ! stallAnimationCounter )
            {
               controlUnit.clear();

               controlUnit.m=255;
               controlUnit.m3=255;
               controlUnit.m18=255;
               controlUnit.m26=255;

               m21 = 255;

               m11=255;
               m17=255;
               m21=255;

               dot1=410;
               dot2=272;

               if ( ! skipAnimation )
               {
                  controlUnit.repaint();
               }

               atBeginBreak = true;
            }

         }

      }

      if(counter1==38)
      {
         // ** LDAC4 **  End of DR <- M
         dot1=287;
         dot2=272;

         theBox.DRint = memoryBox.read( ( int ) theBox.ARint );
         theBox.DR = AssemblyInstruction.toNumberString( theBox.DRint, 2,
            8 );
      }

		if(counter1==37)
		{
			dot1=170;
			dot2=272;

		}

		if(counter1==36)
		{
			dot1=149;
			dot2=272;

		}

		if(counter1==35)
		{
			dot1=149;
			dot2=632;

		}

		if(counter1==34)
		{
			dot1=547;
			dot2=632;

		}

		if(counter1==33)
		{
			dot1=547;
			dot2=150;

		}

		if(counter1==32)
		{
			dot1=548;
			dot2=107;

		}

      if ( counter1 == 31 )
      {
         mcu.setCLKEnabled( false );

         controlUnit.m18 = 0;

         m21 = 0;

         dot1=548;
         dot2=77;

         if ( ! skipAnimation )
         {
            mcu.canvasRepaint();
            controlUnit.repaint();
         }

      }

      if ( counter1 == 30 )
      {
         // ** LDAC4 **  DR <- M

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "LDAC4";

            canCycleBreak = true;
            stallAnimationCounter = true;
         }
         else
         {
            mcu.executeCycle();

            if ( ! stallAnimationCounter )
            {
               controlUnit.clear();

               controlUnit.m=255;
               controlUnit.m3=255;
               controlUnit.m18=255;
               controlUnit.m25=255;

               m21 = 255;

               m14=255;
               m6=255;
               m23=255;

               dot1=520;
               dot2=77;

               if ( ! skipAnimation )
               {
                  controlUnit.repaint();
               }

               atBeginBreak = true;
            }

         }

      }

      if(counter1==29)
      {
         // ** LDAC3 **  End of AR <- DR , TR
         dot1=0;
         dot2=0;

         theBox.ARint = ( ( theBox.DRint << 8 ) & 0xff00 ) + theBox.TRint;
         theBox.AR = AssemblyInstruction.toNumberString( theBox.ARint, 2,
            16 );
      }

		if(counter1==28)
		{


			dot1=287;
			dot2=152;

			//dot3=170;
			//dot4=152;

		}


		if(counter1==27)
		{


			dot1=170;
			dot2=152;

			//dot3=149;
			//dot4=152;


		}

		if(counter1==26)
		{


			dot1=149;
			dot2=152;

			//dot3=149;
			//dot4=632;


		}

		if(counter1==25)
		{


			dot1=149;
			dot2=632;

			//dot3=547;
			//dot4=632;


		}

		if(counter1==24)
		{


			dot1=547;
			dot2=632;

			//dot3=547;
			//dot4=243;


		}

		if(counter1==23)
		{


			dot1=547;
			dot2=332;

			dot3=0;
			dot4=0;


		}

		if(counter1==22)
		{


			dot1=547;
			dot2=332;

			dot3=547;
			dot4=243;


		}

		if(counter1==21)
		{


			dot1=527;
			dot2=332;

			dot3=527;
			dot4=243;


		}

		if(counter1==20)
		{


			dot1=480;
			dot2=332;

			dot3=480;
			dot4=243;


		}

      if ( counter1 == 19 )
      {
         mcu.setCLKEnabled( false );

         controlUnit.m18 = 0;

         m21 = 0;

         dot1=457;
         dot2=332;

         dot3=457;
         dot4=243;

         if ( ! skipAnimation )
         {
            mcu.canvasRepaint();
            controlUnit.repaint();
         }

      }

      if ( counter1 == 18 )
      {
         // ** LDAC3 **  AR <- DR , TR

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "LDAC3";

            canCycleBreak = true;
            stallAnimationCounter = true;
         }
         else
         {
            mcu.executeCycle();

            if ( ! stallAnimationCounter )
            {
               controlUnit.clear();

               controlUnit.m=255;
               controlUnit.m3=255;
               controlUnit.m18=255;
               controlUnit.m24=255;

               m21 = 255;

               m2=255;
               m16=255;
               m18=255;

               dot1=410;
               dot2=332;

               dot3=410;
               dot4=272;

               if ( ! skipAnimation )
               {
                  controlUnit.repaint();
               }

               atBeginBreak = true;
            }

         }

      }

      if ( counter1 == 17 )
      {
         // ** LDAC2 **  End of DR <- M , PC <- PC + 1 , TR <- DR
         dot1=287;
         dot2=272;

         theBox.DRint = memoryBox.read( ( int ) theBox.ARint );
         theBox.DR = AssemblyInstruction.toNumberString( theBox.DRint, 2,
            8 );
      }

		if(counter1==16)
		{
			dot1=170;
			dot2=272;

		}

		if(counter1==15)
		{
			dot1=149;
			dot2=272;

			dot3=0;
			dot4=0;


		}

		if(counter1==14)
		{
			dot1=149;
			dot2=632;

			dot3=287;
			dot4=332;

			theBox.TRint = theBox.DRint;
			theBox.TR = theBox.DR;
		}

		if(counter1==13)
		{
			dot1=547;
			dot2=632;

			dot3=267;
			dot4=332;


		}

		if(counter1==12)
		{
			dot1=547;
			dot2=150;

			dot3=267;
			dot4=309;


		}

		if(counter1==11)
		{
			dot1=548;
			dot2=107;

			dot3=441;
			dot4=309;



		}

      if ( counter1 == 10 )
      {
         mcu.setCLKEnabled( false );

         controlUnit.m18 = 0;

         m21 = 0;

         dot1=548;
         dot2=77;

         dot3=441;
         dot4=273;

         if ( ! skipAnimation )
         {
            mcu.canvasRepaint();
            controlUnit.repaint();
         }

      }

      if ( counter1 == 9 )
      {
         // ** LDAC2 **  TR <- DR , DR <- M , PC <- PC + 1

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "LDAC2";

            canCycleBreak = true;
            stallAnimationCounter = true;
         }
         else
         {
            mcu.executeCycle();

            if ( ! stallAnimationCounter )
            {
               controlUnit.clear();

               controlUnit.m=255;
               controlUnit.m3=255;
               controlUnit.m18=255;
               controlUnit.m23=255;

               m21 = 255;

               m14=255;
               m6=255;
               m5=255;
               m7=255;
               m23=255;

               dot1=520;
               dot2=77;

               dot3=410;
               dot4=272;

               theBox.PCint++;

               if ( theBox.PCint > 0xffff )
               {
                  theBox.PCint &= 0xffff;
               }

               theBox.PC = AssemblyInstruction.toNumberString( theBox.
                  PCint, 2, 16 );

               if ( ! skipAnimation )
               {
                  controlUnit.repaint();
               }

               atBeginBreak = true;
            }

         }

      }

      if(counter1==8)
      {
         // ** LDAC1 **  End of DR <- M , PC <- PC + 1 , AR <- AR + 1
         dot1 = 287;
         dot2 = 272;

         theBox.DRint = memoryBox.read( memoryAddress );
         theBox.DR = AssemblyInstruction.toNumberString( theBox.DRint, 2,
            8 );
      }

		if(counter1==7)
		{
			dot1=170;
			dot2=272;

		}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?