protected void setDestination(short instruction) throws ProgramException {
        boolean destA = (instruction & 0x0020) > 0;
        boolean destD = (instruction & 0x0010) > 0;
        boolean destM = (instruction & 0x0008) > 0;

        if (destM) {
			int address = A.get();
			if (address < 0 || address >= M.getSize())
				throw new ProgramException("At line " + PC.get() +
										   ": Destination is M but A=" +
										   address +
										   " is an illegal memory address.");
            A.setUpdatePointer(true);
			bus.send(alu, 2, M, address);
            A.setUpdatePointer(false);
        }
        if (destA)
            bus.send(alu, 2, A, 0);
        if (destD)
            bus.send(alu, 2, D, 0);
    }