def blocks_from_ops(ops):
    """
    Group a list of :class:`Op` and :class:`Label` instances by label.

    Everytime a label is found, a new :class:`Block` is created. The resulting
    blocks are returned as a dictionary to easily access the target block of a
    jump operation. The keys of this dictionary will be the labels, the values
    will be the :class:`Block` instances. The initial block can be accessed
    by getting the ``None`` item from the dictionary.

    Arguments:
        ops(list): The list of :class:`Op` and :class:`Label` instances (as
            returned by :func:`disassemble`.

    Returns:
        dict: The resulting dictionary of blocks grouped by label.
    """

    blocks = {}
    current_block = blocks[None] = Block()
    for op in ops:
        if isinstance(op, Label):
            next_block = blocks[op] = Block(op)
            current_block.next = next_block
            current_block = next_block
            continue
        current_block.ops.append(op)
    return blocks