cpu.java

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

JAVA
3,404
字号

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

		}

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

		}

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

		}

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

		}

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

		}

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

         controlUnit.m18 = 0;

         m21 = 0;

         dot1 = 548;
         dot2 = 77;

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

      }

      if ( counter1 == 0 )
      {
         // ** LDAC1 **  DR <- M , PC <- PC + 1 , AR <- AR + 1

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "LDAC1";

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

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

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

               m21 = 255;

               m14=255;
               m6=255;
               m5=255;
               m3=255;
               m23=255;

               dot1=520;
               dot2=77;

               theBox.PCint++;

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

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

               // Store address to be used later once data transfer
               // actually occurs
               memoryAddress = ( int ) theBox.ARint;

               theBox.ARint++;

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

               theBox.AR = AssemblyInstruction.toNumberString( theBox.
                  ARint, 2, 16 );

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

               atBeginBreak = true;
            }

         }

      }

      if ( ! stallAnimationCounter )
      {

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

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

      }

   }
*/
// *************************** LDAC ******************************

// ************************* STAC *********************************
/*
   public void STAC()
   {

      if(counter1==48)
      {
         // ** STAC5 **  End of M <- DR
         dot1=520;
         dot2=77;

         memoryBox.write( ( int ) theBox.ARint, ( short ) theBox.DRint );

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

      }

		if(counter1==47)
		{


			dot1=548;
			dot2=77;

		}


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

		}



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

		}

		if(counter1==44)
		{

			dot1=547;
			dot2=272;

		}

		if(counter1==43)
		{

			dot1=527;
			dot2=272;

		}

		if(counter1==42)
		{

			dot1=480;
			dot2=272;

		}

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

         controlUnit.m18 = 0;

         m21 = 0;

         dot1 = 457;
         dot2 = 272;

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

      }

      if ( counter1 == 40 )
      {
         // ** STAC5 **  M <- DR

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "STAC5";

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

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

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

               m21 = 255;

               m17=255;
               m13=255;
               m24=255;

               dot1=410;
               dot2=272;

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

               atBeginBreak = true;
            }

         }

      }

      if(counter1==39)
      {
         // ** STAC4 **  End of DR <- AC
         dot1=287;
         dot2=272;

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

		if(counter1==38)
		{

			dot1=170;
			dot2=272;

		}

		if(counter1==37)
		{

			dot1=149;
			dot2=272;

		}

		if(counter1==36)
		{

			dot1=149;
			dot2=632;

		}

		if(counter1==35)
		{

			dot1=547;
			dot2=632;

		}

		if(counter1==34)
		{

			dot1=547;
			dot2=512;

		}

		if(counter1==33)
		{

			dot1=527;
			dot2=512;

		}

		if(counter1==32)
		{


			dot1=480;
			dot2=512;

		}

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

         controlUnit.m18 = 0;

         m21 = 0;

         dot1=457;
         dot2=512;

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

      }

      if ( counter1 == 30 )
      {
         // ** STAC4 **  DR <- AC

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "STAC4";

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

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

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

               m21 = 255;

               m6=255;
               m20=255;

               dot1=410;
               dot2=512;

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

               atBeginBreak = true;
            }

         }

      }

      if(counter1==29)
      {
         // ** STAC3 **  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;
      }

      if(counter1==27)
      {
         dot1 = 170;
         dot2=152;
      }

      if(counter1==26)
      {
         dot1 = 149;
         dot2=152;
      }

      if(counter1==25)
      {
         dot1=149;
         dot2 = 632;
      }

      if(counter1==24)
      {
         dot1 = 547;
         dot2 = 632;
      }

      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 )
      {
         // ** STAC3 **  AR <- DR , TR

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "STAC3";

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

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

               controlUnit.m=255;
               controlUnit.m4=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)
      {
         // ** STAC2 **  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=319;


		}

		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 )
      {
         // ** STAC2 **  TR <- DR , DR <- M , PC <- PC + 1

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "STAC2";

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

            if ( ! stallAnimationCoun

⌨️ 快捷键说明

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