Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
11
Добавлен:
01.05.2014
Размер:
2 Кб
Скачать
package system_base;

import memory.phithical_mem.PhithicalMemory;
import core.proc_interface.ProcessorInterface;

public class SystemBase {
	private SystemBase(){}
	
	public static byte[] getProcRegState(byte regNumber){
		byte[] regState;
		try{
			regState = ProcessorInterface.registerState(regNumber);			
		}catch(Exception e){
			return null;
		}		
		return regState;
	}

	public static byte getFlagState() {
		return ProcessorInterface.getFlags();
	}

	public static byte[] getProcFRegState(byte fRegNumber) {
		byte[] regState;
		try{
			regState = ProcessorInterface.fRegisterState(fRegNumber);			
		}catch(Exception e){
			return null;
		}		
		return regState;
	}

	public static byte[] getMemPage(int i) {
		byte[] page = new byte[1024];		
		int cur=0;
		
		try{
			byte[] tmp = PhithicalMemory.getStateAvailFromPage(i,false);			
			for(int j=0;j<tmp.length;j++){
				page[cur] = tmp[j];
				cur++;
			}
			}catch(NullPointerException e){
				System.err.println("RISC System: Couldn't read asked page");
				return null;
			}
		
		while(cur<1024){
			try{
			byte[] tmp = PhithicalMemory.getStateAvailFromPage(i,true);			
			for(int j=0;j<tmp.length;j++){
				page[cur] = tmp[j];
				cur++;
			}
			}catch(NullPointerException e){
				System.err.println("RISC System: Couldn't read asked page");
				return null;
			}
		}
		return page;
	}

	public static void writeVar(byte[] var) {
		byte[] inf = PhithicalMemory.rememberVar(var);
		ProcessorInterface.saveVar(inf);
	}

	public static void sendOp(byte[] operation) {
		ProcessorInterface.reciveOperation(operation);
	}

	public static byte[] getVar(byte[] bs) {		
		return PhithicalMemory.getVar(bs);
	}

	public static boolean checkSupervizor() {		
		return ProcessorInterface.checkSupervizorZtate();
	}
}