@Override
	synchronized public boolean applyTo(Program program, TaskMonitor monitor) {

		disassemblyPerformed = false;
		unalignedStart = false;

		// get the M16_MODE register and set accordingly
		Register vlemodeReg = program.getProgramContext().getRegister("vle");

		// if doing mips, and have no M16_MODE reg, no way to do disassemble in mips16
		if (vlemodeReg == null) {
			if (vleMode) {
				setStatusMsg("PowerISA VLE mode not supported");
				return false;
			}
			return super.applyTo(program, monitor);
		}

		RegisterValue vlemodeValue =
			new RegisterValue(vlemodeReg, BigInteger.valueOf(vleMode ? 0x1 : 0x0));
		super.setInitialContext(vlemodeValue);

		int alignment = (vleMode ? 2 : 4);
		long alignMask = vleMode ? ~1 : ~3;

		// Set M16_MODE context on undefined code units only
		try {
			if (startSet != null) {

				// Align startSet so that context only affected at possible instruction starts

				AddressSet alignedSet = new AddressSet();
				for (AddressRange range : startSet) {
					Address min = range.getMinAddress();
					long minOfffset = min.getOffset() & alignMask;
					if (minOfffset != min.getOffset()) {
						min = min.getNewAddress(minOfffset);
					}
					Address max = range.getMaxAddress();
					long maxOffset = max.getOffset() & alignMask;
					if (maxOffset < minOfffset) {
						// skip short unaligned range
						continue;
					}
					if (maxOffset != max.getOffset()) {
						max = max.getNewAddress(maxOffset);
					}
					alignedSet.addRange(min, max);
				}
				if (alignedSet.isEmpty()) {
					unalignedStart = true;
					return false; // alignedSet does not contain any aligned starts
				}
				startSet = program.getListing().getUndefinedRanges(alignedSet, true, monitor);
				if (startSet.isEmpty()) {
					return true; // startSet does not contain any aligned undefined starts 
				}
			}
		}
		catch (CancelledException e) {
			return true;
		}

		return doDisassembly(monitor, program, alignment);
	}
Constructor for PowerPCDisassembleCommand.
@param start address to be the start of a disassembly.
@param restrictedSet addresses that can be disassembled.
a null set implies no restrictions
@param vleMode pass true if the disassembling in PowerISA VLE Mode, otherwise
normal disassembly will be performed.
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/disassemble/PowerPCDisassembleCommand.java