⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpu.java

📁 熟悉非常简单CPU模拟器 1、将所给模拟器的源程序编译成执行程序。 2、运行并观察非常简单CPU模拟器
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      if(counter1==30)
      {
         this.aluBox.d1 = 301;
         this.aluBox.d2 = 130;
      }

      if(counter1==29)
      {
         this.aluBox.d1 = 290;
         this.aluBox.d2 = 130;
         this.aluBox.r6 = 0;
      }

      if(counter1==28)
      {
         this.aluBox.d1 = 255;
         this.aluBox.d2 = 143;
         this.aluBox.r8 = 255;
      }
      
      if(counter1==27)
      {
         this.aluBox.d1 = 219;
         this.aluBox.d2 = 143;

      }

      if(counter1==26)
      {
         this.aluBox.d1 = 219;
         this.aluBox.d2 = 156;

      }

      if(counter1==25)
      {
         this.aluBox.d1 = 209;
         this.aluBox.d2 = 156;

         this.aluBox.d3 = 0;
         this.aluBox.d4 = 0;
      }

      if(counter1==24)
      {
         this.aluBox.d1 = 160;
         this.aluBox.d2 = 145;
         this.aluBox.r4 = 0;

         this.aluBox.d3 = 160;
         this.aluBox.d4 = 171;
         this.aluBox.r3 = 0;
      }

      if(counter1==23)
      {
         this.aluBox.d1 = 123;
         this.aluBox.d2 = 145;

         this.aluBox.d3 = 143;
         this.aluBox.d4 = 171;
      }

      if(counter1==22)
      {
         this.aluBox.d1 = 123;
         this.aluBox.d2 = 80;

         this.aluBox.d3 = 123;
         this.aluBox.d4 = 171;
      }

      if(counter1==21)
      {
         this.aluBox.d1 = 92;
         this.aluBox.d2 = 80;
         this.aluBox.r4 = 255;

         this.aluBox.d3 = 92;
         this.aluBox.d4 = 171;
         this.aluBox.r3 = 255;
      }

      if ( counter1 == 20 ) { } // added so graphic of alu is fully visible

      if ( counter1 == 19 )
      {

         if ( ! skipAnimation )
         {
//            aluBox.setLocation(568,295);
            aluBox.setVisible( true );
         }

         dot1 = 0;
         dot2 = 0;
         dot3 = 0;
         dot4 = 0;

         counter1++;
         tempcounter = counter1 - 1;
      }

      if ( counter1 == 31 )
      {
         counter1 = tempcounter;
         counter2 = 1;

         aluBox.setVisible( false );
      }
      else
      {
         counter1++;

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

      }

   }

//*************************END ADDALU**************************

//*************************BEGIN INCALU***********************

   public void INCALU()
   {

      if(counter1==18)
      {
         this.aluBox.d1 = 0;
         this.aluBox.d2 = 0;
         this.aluBox.r8 = 0;
      }

      if(counter1==17)
      {
         this.aluBox.d1 = 301;
         this.aluBox.d2 = 130;
      }

      if(counter1==16)
      {
         this.aluBox.d1 = 290;
         this.aluBox.d2 = 130;
         this.aluBox.r6 = 0;
      }

      if(counter1==15)
      {
         this.aluBox.d1 = 255;
         this.aluBox.d2 = 143;
         this.aluBox.r8 = 255;
      }

      if(counter1==14)
      {
         this.aluBox.d1 = 219;
         this.aluBox.d2 = 143;
      }

      if(counter1==13)
      {
         this.aluBox.d1 = 219;
         this.aluBox.d2 = 156;
      }

      if(counter1==12)
      {
         this.aluBox.d1 = 209;
         this.aluBox.d2 = 156;
      }

      if(counter1==11)
      {
         this.aluBox.d1 = 160;
         this.aluBox.d2 = 145;
         this.aluBox.r3 = 0;
         this.aluBox.r6 = 255;
      }

      if(counter1==10)
      {
         this.aluBox.d1 = 123;
         this.aluBox.d2 = 145;
      }

      if(counter1==9)
      {
         this.aluBox.d1 = 123;
         this.aluBox.d2 = 80;
      }

      if ( counter1 == 8 )
      {
         this.aluBox.d1 =95;
         this.aluBox.d2 = 80;
         this.aluBox.r3 = 255;
         this.aluBox.r5 = 255;
      }

      if ( counter1 == 7 ) { }  // added so graphic of alu is fully visible

      if ( counter1 == 6 )
      {

         if ( ! skipAnimation )
         {
//            aluBox.setLocation(568,295);
            aluBox.setVisible( true );
         }

         dot1 = 0;
         dot2 = 0;
         dot3 = 0;
         dot4 = 0;

         counter1++;
         tempcounter = counter1 - 1;
      }

      if ( counter1 == 18 )
      {
         counter1 = tempcounter;
         counter2 = 1;

         aluBox.setVisible( false );
      }
      else
      {
         counter1++;

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

      }

   }

//*************************END INCALU*************************

//*************************BEGIN CLACALU***********************
/*
   public void CLACALU()
   {

      if ( counter1 == 14 )
      {
         this.aluBox.d1 = 250;
         this.aluBox.d2 = 265;
      }

      if(counter1==13)
      {
         this.aluBox.d1 = 250;
         this.aluBox.d2 = 255;
      }

      if(counter1==12)
      {
         this.aluBox.d1 = 238;
         this.aluBox.d2 = 220;
      }

      if(counter1==11)
      {
         this.aluBox.d1 = 238;
         this.aluBox.d2 = 202;
      }

      if(counter1==10)
      {
         this.aluBox.d1 = 138;
         this.aluBox.d2 = 202;
      }

      if(counter1==9)
      {
         this.aluBox.d1 = 138;
         this.aluBox.d2 = 185;
         this.aluBox.d3 = 0;
         this.aluBox.d4 = 0;
      }

      if(counter1==8)
      {
         this.aluBox.d1 = 145;
         this.aluBox.d2 = 150;
         this.aluBox.d3 = 125;
         this.aluBox.d4 = 150;
      }

      if(counter1==7)
      {
         this.aluBox.d1 = 145;
         this.aluBox.d2 = 132;
         this.aluBox.d3 = 125;
         this.aluBox.d4 = 132;
      }

      if(counter1==6)
      {
         this.aluBox.d1 = 183;
         this.aluBox.d2 = 132;
         this.aluBox.d3 = 88;
         this.aluBox.d4 = 132;
         //this.aluBox.r1 = 0;
      }

      if(counter1==5)
      {
         this.aluBox.d1 = 183;
         this.aluBox.d2 = 115;
         this.aluBox.d3 = 88;
         this.aluBox.d4 = 115;
      }

      if(counter1==4)
      {
         this.aluBox.d1 = 155;
         this.aluBox.d2 = 80;
         this.aluBox.d3 = 75; ////////////////////////////////////////////////?
         this.aluBox.d4 = 80; /////////////////////////////////////////////////?
      }

      if ( counter1 == 3 )
      {
         this.aluBox.d1 = 155;
         this.aluBox.d2 = 70;
         this.aluBox.d3 = 75; //100//////////////////////////////////////////////?
         this.aluBox.d4 = 70; /////////////////////////////////////////////////?
         // this.aluBox.r1 = 255;
      }

      if ( counter1 == 2 ) { }  // added so graphic of alu is fully visible

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

         controlUnit.m18 = 0;

         m21 = 0;

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

//            aluBox.setLocation(568,295);
            aluBox.setVisible( true );
         }

         dot1 = 0;
         dot2 = 0;
         dot3 = 0;
         dot4 = 0;

         counter1++;
         tempcounter = counter1 - 1;
      }

      if ( counter1 == 14 )
      {
         counter1 = tempcounter;
         counter2 = 1;

         aluBox.setVisible( false );
      }
      else
      {
         counter1++;

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

      }

   }
*/
//*************************END CLACALU************************

//************************BEGIN MOVRALU*********************
/*
   public void MOVRALU()
   {

      if(counter1==23)
      {
         this.aluBox.d1 = 250;
         this.aluBox.d2 = 265;
      }

      if(counter1==22)
      {
         this.aluBox.d1 = 250;
         this.aluBox.d2 = 255;
      }

      if(counter1==21)
      {
         this.aluBox.d1 = 238;
         this.aluBox.d2 = 220;
      }

      if(counter1==20)
      {
         this.aluBox.d1 = 238;
         this.aluBox.d2 = 202;
      }

      if(counter1==19)
      {
         this.aluBox.d1 = 138;
         this.aluBox.d2 = 202;
      }

      if(counter1==18)
      {
         this.aluBox.d1 = 138;
         this.aluBox.d2 = 185;
      }

      if(counter1==17)
      {
         this.aluBox.d1 = 145;
         this.aluBox.d2 = 150;
      }

      if(counter1==16)
      {
         this.aluBox.d1 = 145;
         this.aluBox.d2 = 132;
      }

      if(counter1==15)
      {
         this.aluBox.d1 = 183;
         this.aluBox.d2 = 132;
         this.aluBox.r1 = 0;
      }

      if(counter1==14)
      {
         this.aluBox.d1 = 183;
         this.aluBox.d2 = 115;
      }

      if(counter1==13)
      {
         this.aluBox.d1 = 179;
         this.aluBox.d2 = 80;
      }

      if(counter1==12)
      {
         this.aluBox.d1 = 179;
         this.aluBox.d2 = 70;
         this.aluBox.r1 = 255;
      }

      if(counter1==11) { }  //added so graphic of alu is fully visible

      if(counter1==10)
      {

         if ( ! skipAnimation )
         {
//            aluBox.setLocation(568,295);
            aluBox.setVisible( true );
         }

         dot1 = 0;
         dot2 = 0;
         dot3 = 0;
         dot4 = 0;

         counter1++;
         tempcounter = counter1 - 1;
      }

      if ( counter1 == 23 )
      {
         counter1 = tempcounter;
         counter2 = 1;

         aluBox.setVisible( false );
      }
      else
      {
         counter1++;

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

      }

   }
*/
//************************END MOVRALU***********************

//*************************BEGIN LDACALU*********************
/*
   public void LDACALU()
   {

      if(counter1==62)
      {
		this.aluBox.d1 = 250;
		this.aluBox.d2 = 265;
      }

      if(counter1==61)
      {
                this.aluBox.d1 = 250;
                this.aluBox.d2 = 255;
      }

      if(counter1==60)
      {
		this.aluBox.d1 = 238;
		this.aluBox.d2 = 220;
      }

      if(counter1==59)
      {
                this.aluBox.d1 = 238;
                this.aluBox.d2 = 202;
      }

      if(counter1==58)
      {
		this.aluBox.d1 = 138;
		this.aluBox.d2 = 202;
      }

      if(counter1==57)
      {
                this.aluBox.d1 = 138;
                this.aluBox.d2 = 185;
      }

      if(counter1==56)
      {
		this.aluBox.d1 = 145;
		this.aluBox.d2 = 150;
      }

      if(counter1==55)
      {
                this.aluBox.d1 = 145;
                this.aluBox.d2 = 132;
      }

      if(counter1==54)
      {
		this.aluBox.d1 = 183;
                this.aluBox.d2 = 132;
                this.aluBox.r1 = 0;
      }

      if(counter1==53)
      {
                this.aluBox.d1 = 183;
                this.aluBox.d2 = 115;
      }

      if(counter1==52)
      {
		this.aluBox.d1 = 179;
		this.aluBox.d2 = 80;
      }

      if(counter1==51)
      {
                this.aluBox.d1 = 179;
                this.aluBox.d2 = 70;
                this.aluBox.r1 = 255;
      }

      if ( counter1 == 50 ) { } // added so graphic of alu is fully visible

      if ( counter1 == 49 )
      {

         if ( ! skipAnimation )
         {
//            aluBox.setLocation(568,295);
            aluBox.setVisible( true );
         }

         dot1 = 0;
         dot2 = 0;
         dot3 = 0;
         dot4 = 0;

         counter1++;
         tempcounter = counter1 - 1;
      }

      if ( counter1 == 62 )
      {
         counter1 = tempcounter;
         counter2 = 1;

         aluBox.setVisible( false );
      }
      else
      {
         counter1++;

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

      }

   }
*/
//*****************************END LDACALU**********************

//*************************** BEGIN NOP ******************************
/*
   public void NOP()
   {

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

         controlUnit.m18 = 0;

         m21 = 0;

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

      }

      if ( counter1 == 0 )
      {

         if ( atBeginBreak )
         {
            clear();

            currentRTL = "NOP";

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

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

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

               m21 = 255;

               if ( ! skipAnimation )
               {

⌨️ 快捷键说明

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