def pformat_program_dump(self, program_dump, program_start, formated_dump=None):
        """
        format a BASIC program dump. Useful for debugging.
        returns a list of formated string lines.
        """
        if formated_dump is None:
            formated_dump = []
            formated_dump.append(
                "program start address: $%04x" % program_start
            )

        assert isinstance(program_dump, bytearray)

        if not program_dump:
            return program_dump

        try:
            next_address = (program_dump[0] << 8) + program_dump[1]
        except IndexError as err:
            raise IndexError(
                "Can't get next address from: %s program start: $%04x (Origin error: %s)" % (
                    repr(program_dump), program_start, err
            ))

        if next_address == 0x0000:
            formated_dump.append("$%04x -> end address" % next_address)
            return formated_dump

        assert next_address > program_start, "Next address $%04x not bigger than program start $%04x ?!?" % (
            next_address, program_start
        )

        length = next_address - program_start
        formated_dump.append(
            "$%04x -> next address (length: %i)" % (next_address, length)
        )
        line_number = (program_dump[2] << 8) + program_dump[3]
        formated_dump.append("$%04x -> %i (line number)" % (line_number, line_number))

        tokens = program_dump[4:length]
        formated_dump.append("tokens:")
        formated_dump += self.token_util.pformat_tokens(tokens)

        return self.pformat_program_dump(program_dump[length:], next_address, formated_dump)