public static ByteBuffer prepareBuffer(Register register) {
		/*
		 * The byte array for reg values spans the whole base register, but we'd like to avoid
		 * over-reading, so we'll zero in on the bytes actually included in the mask. We'll then
		 * have to handle endianness and such. The regval instance should then apply the actual mask
		 * for the sub-register, if applicable.
		 */
		int byteLength = register.getNumBytes();
		byte[] mask = register.getBaseMask();
		ByteBuffer buf = ByteBuffer.allocate(mask.length * 2);
		buf.put(mask);
		int maskOffset = TraceRegisterUtils.computeMaskOffset(register);
		int startVal = buf.position() + maskOffset;
		buf.position(startVal);
		buf.limit(buf.position() + byteLength);
		return buf;
	}
Convert a set in an overlay space to the corresponding set in its physical space

@param set a set contained entirely in one space
@return the physical set
Ghidra/Debug/Framework-TraceModeling/src/main/java/ghidra/trace/util/TraceRegisterUtils.java