public static void loadDirectReferenceList(Program program, int alignment, Address toAddress,
			AddressSetView toAddressSet, Accumulator<ReferenceAddressPair> accumulator,
			TaskMonitor monitor) throws CancelledException {

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

		Memory memory = program.getMemory();
		boolean isBigEndian = memory.isBigEndian();
		int unitSize = toAddress.getAddressSpace().getAddressableUnitSize(); //number of bytes per addressable unit
		int addrSize = toAddress.getSize();
		short currentSegment = 0;

		if (toAddressSet == null || toAddressSet.getNumAddresses() == 1) {
			Set<Address> refAddrs = findDirectReferences(program, alignment, toAddress, monitor);
			Iterator<Address> refAddrIter = refAddrs.iterator();
			while (refAddrIter.hasNext() && !monitor.isCancelled()) {
				accumulator.add(new ReferenceAddressPair(refAddrIter.next(), toAddress));
			}
			return;
		}

		// Just looking for the offset into the segment now, not the whole segment/offset pair
		if (toAddress instanceof SegmentedAddress) {
			SegmentedAddress segAddr = (SegmentedAddress) toAddress;
			currentSegment = (short) segAddr.getSegment();
		}

		// iterate over addresses in program
		AddressIterator addrIt = memory.getLoadedAndInitializedAddressSet().getAddresses(true);
		monitor.initialize(memory.getNumAddresses());
		int count = 0;
		while (addrIt.hasNext()) {
			monitor.checkCancelled();
			Address a = addrIt.next();
			++count;
			monitor.setProgress(count);

			if ((a.getOffset() % alignment) != 0) {
				continue;
			}

			long addrLong = 0;
			long addrLongShifted = 0;
			try {
				if (toAddress instanceof SegmentedAddress) {
					short offsetShort = memory.getShort(a);
					offsetShort &= offsetShort & 0xffff;
					// this is checking to see if the ref is in the same segment as the toAddr - not sure this is needed anymore
					// SegmentedAddress sega = ((SegmentedAddress) a);
					// short shortSega = (short) (sega.getSegment());
					// shortSega &= shortSega & 0xffff;
					//	if (offsetShort == shortCurrentOffset) {
					//*** commenting this out is making it find the instances of 46 01's not the 0a 00's - closer though
					// check for the case where the reference includes both the segment and offset
					// and the case where the reference includes only the offset but the address being checked
					// is in the same segment as the current address
					//if ((segmentShort == currentSegment) || (shortSega == currentSegment)) {
					//	addrLong = longCurrentAddress; // this is only so that the check below works
					//}
					addrLong = offsetShort;
					//	}
				}
				else if (addrSize == 16) {
					short addrShort = memory.getShort(a);
					addrLong = addrShort & 0xffffL; // multiply by wordsize because 
					// address offsets are at the byte level,
					// not the addressable word level.
				}
				else if (addrSize == 32) {
					int addrInt = memory.getInt(a);
					addrLong = addrInt & 0xffffffffL;
				}
				else if (addrSize == 64) {
					addrLong = memory.getLong(a);
				}
				else {
					// handle any addrSize the hard way
					byte dest[] = new byte[addrSize / 8];
					int num = memory.getBytes(a, dest);
					if (num != dest.length) {
						continue; // insufficient bytes
					}
					addrLong = 0;
					for (int i = 0; i < dest.length; i++) {
						int destIndex = isBigEndian ? i : (dest.length - i - 1);
						addrLong = (addrLong << 8) | (dest[destIndex] & 0xff);
					}
				}

				Address addr;
				if (toAddress instanceof SegmentedAddress) {
					SegmentedAddressSpace space =
						(SegmentedAddressSpace) toAddress.getAddressSpace();
					addr = space.getAddress(currentSegment, (int) addrLong);
				}
				else {
					addr = toAddress.getNewAddress(addrLong * unitSize);
				}

				Address addrShifted = null;
				int addressShiftAmount =
					program.getDataTypeManager().getDataOrganization().getPointerShift();
				if (addressShiftAmount != 0) {
					// look for addresses that are shifted for those processors who
					// store shifted pointers
					addrLongShifted = addrLong << addressShiftAmount;
					try {
						addrShifted = toAddress.getNewAddress(addrLongShifted * unitSize);
					}
					catch (AddressOutOfBoundsException e) {
						// ignore for now; the null check happens below
					}
				}

				// TODO: This is flawed since the wrong unitSize may have been used to create addr
				//       Each address-space may have a different unitSize - it's a little weird
				//       to have both a toAddress and a toAddressSet specified where toAddress is required
				if (toAddressSet.contains(addr)) {
					accumulator.add(new ReferenceAddressPair(a, addr));
				}
				if (addrShifted != null && toAddressSet.contains(addrShifted)) {
					accumulator.add(new ReferenceAddressPair(a, addrShifted));
				}
			}
			catch (MemoryAccessException e) {
				// ignore (tsk, tsk)
			}
			catch (AddressOutOfBoundsException e) {
				// ignore (tsk, tsk)
			}
		}
	}
Checks a programs memory for direct references to the addresses indicated in the toAddressSet.
Direct references are only found at addresses that match the indicated alignment. Each
direct reference is added to the directReferenceList as a from/to address pair.

@param program the program whose memory is to 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 toAddressSet address set indicating the addresses that we are interested in 
		  finding directly referred to in memory. 
		  Null if only interested in finding references to the toAddress.
@param accumulator the datastructure to be populated with possible direct references
@param monitor a task monitor for progress or to allow cancelling.
@throws CancelledException if the user cancels via the monitor.
Ghidra/Features/Base/src/main/java/ghidra/program/util/ProgramMemoryUtil.java