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

📄 cpu.java

📁 熟悉非常简单CPU模拟器 1、将所给模拟器的源程序编译成执行程序。 2、运行并观察非常简单CPU模拟器
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
         simulationStartNumber = ( int ) theBox.PCint;
      }
      else if ( eventSource == editDRMenuItem )
      {
	 editRegisterDialog = new EditRegisterDialog( this, 
            "Edit Register", true, EditRegisterDialog.REG_DR );

         Dimension screenSize = Toolkit.getDefaultToolkit().
            getScreenSize();
         Dimension editRegisterDialogSize = editRegisterDialog.getSize();
         Point editRegisterDialogLocation = new Point( ( screenSize.width -
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
      }
     /* else if ( eventSource == editTRMenuItem )
      {
	 editRegisterDialog = new EditRegisterDialog( this, 
            "Edit Register", true, EditRegisterDialog.REG_TR );

         Dimension screenSize = Toolkit.getDefaultToolkit().
            getScreenSize();
         Dimension editRegisterDialogSize = editRegisterDialog.getSize();
         Point editRegisterDialogLocation = new Point( ( screenSize.width -
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
      }
      else if ( eventSource == editTRMenuItem )
      {
	 editRegisterDialog = new EditRegisterDialog( this, 
            "Edit Register", true, EditRegisterDialog.REG_TR );

         Dimension screenSize = Toolkit.getDefaultToolkit().
            getScreenSize();
         Dimension editRegisterDialogSize = editRegisterDialog.getSize();
         Point editRegisterDialogLocation = new Point( ( screenSize.width -
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
      }*/
      else if ( eventSource == editIRMenuItem )
      {
	 editRegisterDialog = new EditRegisterDialog( this, 
            "Edit Register", true, EditRegisterDialog.REG_IR );

         Dimension screenSize = Toolkit.getDefaultToolkit().
            getScreenSize();
         Dimension editRegisterDialogSize = editRegisterDialog.getSize();
         Point editRegisterDialogLocation = new Point( ( screenSize.width -
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
      }
     /* else if ( eventSource == editRMenuItem )
      {
	 editRegisterDialog = new EditRegisterDialog( this, 
            "Edit Register", true, EditRegisterDialog.REG_R );

         Dimension screenSize = Toolkit.getDefaultToolkit().
            getScreenSize();
         Dimension editRegisterDialogSize = editRegisterDialog.getSize();
         Point editRegisterDialogLocation = new Point( ( screenSize.width -
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
      }*/
      else if ( eventSource == editACMenuItem )
      {
	 editRegisterDialog = new EditRegisterDialog( this, 
            "Edit Register", true, EditRegisterDialog.REG_AC );

         Dimension screenSize = Toolkit.getDefaultToolkit().
            getScreenSize();
         Dimension editRegisterDialogSize = editRegisterDialog.getSize();
         Point editRegisterDialogLocation = new Point( ( screenSize.width -
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
      }
     /* else if ( eventSource == editZMenuItem )
      {
	 editRegisterDialog = new EditRegisterDialog( this, 
            "Edit Register", true, EditRegisterDialog.REG_Z );

         Dimension screenSize = Toolkit.getDefaultToolkit().
            getScreenSize();
         Dimension editRegisterDialogSize = editRegisterDialog.getSize();
         Point editRegisterDialogLocation = new Point( ( screenSize.width -
            editRegisterDialogSize.width ) / 2, ( screenSize.height -
            editRegisterDialogSize.height ) / 2 );

         editRegisterDialog.setLocation( editRegisterDialogLocation );
         editRegisterDialog.setVisible( true );
      }*/
      else if ( eventSource == clearRegistersMenuItem )
      {
         clearRegisters();
         cpuCanvas.repaint();
      }
      else if ( eventSource == stepInstructionMenuItem )
      {
         instructionBreakNow = true;

         if ( runner == null )
         {
            startAnimation();
         }

      }
      else if ( eventSource == stepCycleMenuItem )
      {
         cycleBreakNow = true;

         if ( runner == null )
         {
            startAnimation();
         }

      }


   }

   public void dumpRegs()
   {

        //String theBox_R=cv(theBox.R)+offset;
        String theBox_AC=cv(theBox.AC);
        //String theBox_Z=cv(theBox.Z)+offset;
        String theBox_AR=cv(theBox.AR);
        String theBox_PC=cv(theBox.PC);
        String theBox_DR=cv(theBox.DR);
        //String theBox_TR=cv(theBox.TR)+offset;
        String theBox_IR=cv(theBox.IR);
        String offset="";
        if(!bin){
                offset="\t";
         }

      TraceResults.traceBox.append("	  	" + theBox_AR + "\t\t" + theBox_PC + "\t\t" + theBox_DR 
					+ "\t"+offset + theBox_IR + "\t\t"  + theBox_AC + "\t\t" + newline );	    

	
   }
   
   
//*************************BEGIN NOTALU**********************
/*
   public void NOTALU()
   {

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

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

      if(counter1==16)
      {
         this.aluBox.d1 = 263;
         this.aluBox.d2 = 220;
      }

      if(counter1==15)
      {
		this.aluBox.d1 = 263;
		this.aluBox.d2 = 202;
      }

      if(counter1==14)
      {
         this.aluBox.d1 = 395;
         this.aluBox.d2 = 202;
         this.aluBox.r7 = 0;
         this.aluBox.r8 = 0;
      }

      if(counter1==13)
      {
		this.aluBox.d1 = 395;
		this.aluBox.d2 = 185;
      }

      if(counter1==12)
      {
         this.aluBox.d1 = 440;
         this.aluBox.d2 = 150;
      }

      if(counter1==11)
      {
		this.aluBox.d1 = 440;
		this.aluBox.d2 = 140;
      }

      if(counter1==10)
      {
         this.aluBox.d1 = 440;
         this.aluBox.d2 = 120;
      }

      if(counter1==9)
      {
		this.aluBox.d1 = 440;
		this.aluBox.d2 = 90;
      }

      if(counter1==8)
      {
         this.aluBox.d1 = 470;
         this.aluBox.d2 = 90;
         this.aluBox.r8 = 255;
         this.aluBox.r7 = 255;
         this.aluBox.r6 = 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 NOTALU************************

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

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

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

      if(counter1==20)
      {
         this.aluBox.d1 = 263;
         this.aluBox.d2 = 220;
      }

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

      if(counter1==18)
      {
         this.aluBox.d1 = 395;
         this.aluBox.d2 = 202;
         this.aluBox.r7 = 0;
      }

      if(counter1==17)
      {
         this.aluBox.d1 = 395;
         this.aluBox.d2 = 185;
      }

      if(counter1==16)
      {
         this.aluBox.d1 = 410;
         this.aluBox.d2 = 150;
      }

      if(counter1==15)
      {
         this.aluBox.d1 = 410;
         this.aluBox.d2 = 140;
         this.aluBox.d3 = 0;
         this.aluBox.d4 = 0;
      }

      if(counter1==14)
      {
         this.aluBox.d1 = 407;
         this.aluBox.d2 = 124;
         this.aluBox.d3 = 413;
         this.aluBox.d4 = 124;
      }

      if(counter1==13)
      {
         this.aluBox.d1 = 407;
         this.aluBox.d2 = 90;
         this.aluBox.d3 = 413;
         this.aluBox.d4 = 105;
      }

      if(counter1==12)
      {
         this.aluBox.d1 = 470;
         this.aluBox.d2 = 90;
         this.aluBox.d3 = 470;
         this.aluBox.d4 = 105;
         this.aluBox.r7 = 255;
         this.aluBox.r6 = 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 == 22 )
      {
         counter1 = tempcounter;
         counter2 = 1;

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

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

      }

   }
*/
//*************************END XORALU************************

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

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

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

      if(counter1==20)
      {
         this.aluBox.d1 = 263;
         this.aluBox.d2 = 220;
      }

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

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

      if(counter1==17)
      {
         this.aluBox.d1 = 395;
         this.aluBox.d2 = 185;
      }

      if(counter1==16)
      {
         this.aluBox.d1 = 380;
         this.aluBox.d2 = 150;
      }

      if(counter1==15)
      {
         this.aluBox.d1 = 380;
         this.aluBox.d2 = 140;
         this.aluBox.d3 = 0;
         this.aluBox.d4 = 0;
      }

      if(counter1==14)
      {
         this.aluBox.d1 = 377;
         this.aluBox.d2 = 124;
         this.aluBox.d3 = 383;
         this.aluBox.d4 = 124;
      }

      if(counter1==13)
      {
         this.aluBox.d1 = 377;
         this.aluBox.d2 = 90;
         this.aluBox.d3 = 383;
         this.aluBox.d4 = 105;
      }

      if(counter1==12)
      {
         this.aluBox.d1 = 470;
         this.aluBox.d2 = 90;
         this.aluBox.d3 = 470;
         this.aluBox.d4 = 105;
         this.aluBox.r8 = 255;
         this.aluBox.r6 = 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 == 22 )
      {
         counter1 = tempcounter;
         counter2 = 1;

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

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

      }

   }
*/
//*************************END ORALU**************************

//*************************BEGIN ANDALU***********************

   public void ANDALU()
   {
      if(counter1==31)
      {
         this.aluBox.d1 = 0;
         this.aluBox.d2 = 0;
         this.aluBox.r8 = 0;
         this.aluBox.r7 = 0;
      }

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

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

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

      }

      if(counter1==26)
      {
         this.aluBox.d1 = 244;
         this.aluBox.d2 = 85;

      }

      if(counter1==25)
      {
         this.aluBox.d1 = 205;
         this.aluBox.d2 = 85;

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

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

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

      if(counter1==23)
      {
         this.aluBox.d1 = 143;
         this.aluBox.d2 = 80;

         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;

         this.aluBox.r7 = 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 ANDALU*************************

//*************************BEGIN ADDALU************************

   public void ADDALU()
   {
      if(counter1==31)
      {
         this.aluBox.d1 = 0;
         this.aluBox.d2 = 0;
         this.aluBox.r8 = 0;
      }

⌨️ 快捷键说明

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