/* * // Chops off first four and last two bits of 32-bit immediate, as specified by MIPS J-type format * private uint EncodeJumpImmediate(string hex) * { * string newHex = hex.Substring(2,hex.Length-2); * string binary = ASMValueHelper.HexToBinary(newHex); * return binary.Substring(4,binary.Length-6); * } */ private uint EncodeBranchImmediate(uint val, uint pc, uint mask) { int difference = unchecked ((int)((val - pc - 4) / 4)); //string hexImmed = ASMValueHelper.SignedToHex_WithLength(difference, 4); //return ASMValueHelper.HexToBinary_WithLength(hexImmed, 16); return(ASMValueHelper.SignedToUnsigned(difference) & mask); }
private uint EncodeImmediate(int immed, int length, uint mask) { //return ASMValueHelper.UnsignedToBinaryAny_WithLength(immed, length); return(ASMValueHelper.SignedToUnsigned(immed) & mask); }
private uint EncodeBranchImmediate(uint val, uint pc, uint mask) { int difference = unchecked ((int)((val - pc - 4) / 4)); return(ASMValueHelper.SignedToUnsigned(difference) & mask); }