29. public static final int DEFAULT_MEMORY_SIZE = 1 * 1024 * 1024;
public static final int AX = 0;
public static final int CX = 1;
public static final int DX = 2;
public static final int BX = 3;
public static final int SI = 6;
public Emulator(int memorySize){
memory = new byte[memorySize]; //プログラムを格納する領域の確保
registers = new int[7]; //現在はレジスタ7つ目まで使う
eip = 0; //プログラムカウンタ
/*** この初期化追加 ***/
text = new StringBuilder();
}
public void read(String fileName) throws IOException{
BufferedInputStream input = null;
try{
input = new BufferedInputStream(new FileInputStream(fileName));
//プログラムを読み込む
input.read(memory);
input.close();
}catch(IOException e){
if(input != null){
try{
input.close();
}catch(IOException ioe){
throw ioe;
}
}
throw e;
}
}
public void execute(){
//オペコードの取得
int code = memory[eip] & 0xFF;
29