main.java

来自「用jAVA实现的一个CPU32位的指令代码」· Java 代码 · 共 40 行

JAVA
40
字号
import java.io.File;
import java.io.IOException;

public class Main {

	public static void main(String[] args) throws IOException {

		/*
		 * Demo one: 
		 * movl 9, x 
		 * movl -8, y 
		 * addl x, y 
		 * print y # result is 1
		 */

		System.out.println("MiniPentium demo one:");
		System.out.println("movl 9, x\nmovl -8, y\naddl x, y\nprint y # result is 1\n");
		File exefile = new File("src", "Test1.exe");
		Vcpu cpu = new Vcpu(new Memory());
		cpu.loader(exefile);
		cpu.start();
		/*Demo two: 
		 * movl 9 , x 
		 * movl -8 , y
		 * movl 10 , z 
		 * addl x , y 
		 * subl y , z
		 * mull x , z 
		 * print z 
		 * print x 
		 * print y
		 */
		File exefile2=new File("src","Test2.exe");
		cpu.reset(new Memory());
		cpu.loader(exefile2);
		cpu.start();

	}
}

⌨️ 快捷键说明

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