package ga050426;

public class BitsManipulator {
	public static byte getOpcode(byte IRh){
		byte temp=IRh;
		temp>>=2;
		return (byte)(temp & 0x3f);
	}
	public static byte getDataFromOpcode(byte IRh){
		byte high=IRh;
		high<<=6;
		high>>=6;
		return high;
	}
	public static short getShortFromTwoBytes(byte MEMh, byte MEMl){
		short temph = MEMh;
		temph<<=8;
		short templ = MEMl;
		templ &= (short)0x00ff;
		return (short)(temph | templ);
		
	}
	public static byte getByteFromInput(String input){
		int word = Integer.decode("0x"+input);
		word &= 0x00ff;
		return (byte)word;
	}
	public static byte getHigherByte(short word) {
		return (byte) (Integer.rotateRight(word, 8));
	}

	public static byte getLowerByte(short word) {
		return (byte) word;
	}
}
