public static Set<Address> findDirectReferences(Program program, List<MemoryBlock> blocks,
			int alignment, Address toAddress, TaskMonitor monitor) throws CancelledException {

		if (monitor == null) {
			monitor = TaskMonitor.DUMMY;
		}

		byte[] addressBytes = getDirectAddressBytes(program, toAddress);

		byte[] shiftedAddressBytes = getShiftedDirectAddressBytes(program, toAddress);

		Memory memory = program.getMemory();
		Set<Address> dirRefsAddrs = new TreeSet<>();
		findBytePattern(memory, blocks, addressBytes, alignment, dirRefsAddrs, monitor);

		if (shiftedAddressBytes != null) { // assume shifted address not supported with segmented memory
			findBytePattern(memory, blocks, shiftedAddressBytes, alignment, dirRefsAddrs, monitor);
		}

		return dirRefsAddrs;
	}
Checks a programs memory for direct references to the address indicated within the 
listed memory blocks. If null is passed for the list of memory blocks then all of the
program's memory blocks will be checked.<br>
Direct references are only found at addresses that match the indicated alignment. 

@param program the program whose memory is to be checked.
@param blocks the only memory blocks to be checked. A null value indicates all memory 
blocks should be checked.
@param alignment direct references are to only be found at the indicated alignment in memory.
@param toAddress address that we are interested in finding references to.
@param monitor a task monitor for progress or to allow canceling.
@return list of addresses referring directly to the toAddress

@throws CancelledException if the user cancels via the monitor.
Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramMemoryUtil.java