public static long constructValue(byte[] ptr, int offset, int size, boolean bigendian) {
		long res = 0;

		if (bigendian) {
			for (int i = 0; i < size; ++i) {
				res <<= 8;
				res |= ptr[i + offset] & 0xffL;
			}
		}
		else {
			for (int i = size - 1; i >= 0; --i) {
				res <<= 8;
				res |= ptr[i + offset] & 0xffL;
			}
		}
		return res;
	}
This is a static convenience routine for decoding a value from a sequence of bytes depending
on the desired endianness

@param ptr is the pointer to the bytes to decode
@param offset a fixed offset from {@code ptr} used during decode
@param size is the number of bytes
@param bigendian is true if the bytes are encoded in big endian form
@return the decoded value
Ghidra/Framework/Emulation/src/main/java/ghidra/pcode/memstate/MemoryBank.java