• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • ACL2
    • Macro-libraries
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
        • Sdm-instruction-set-summary
        • Tlb
        • Running-linux
        • Introduction
        • Asmtest
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
          • X86isa-state
          • Syscalls
          • Cpuid
          • Linear-memory
          • Rflag-specifications
          • Characterizing-undefined-behavior
          • Top-level-memory
          • App-view
          • X86-decoder
          • Physical-memory
          • Decoding-and-spec-utils
          • Instructions
          • Register-readers-and-writers
          • X86-modes
          • Segmentation
          • Other-non-deterministic-computations
          • Environment
            • Components-of-the-environment-field
            • Reading-memory-as-strings-or-bytes
              • Read-bytes-from-memory
              • Read-memory-zero-terminated
                • Read-string-zero-terminated
                • Read-string-from-memory
              • Converting-between-strings-and-bytes
              • Writing-strings-or-bytes-to-memory
            • Paging
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Reading-memory-as-strings-or-bytes

    Read-memory-zero-terminated

    Read memory as bytes till a zero is encountered

    Signature
    (read-memory-zero-terminated ptr x86 acc) → (mv * * x86)

    Returns a list of bytes (byte at the smallest address is the first byte of the list).

    Definitions and Theorems

    Function: read-memory-zero-terminated

    (defun read-memory-zero-terminated (ptr x86 acc)
     (declare (xargs :stobjs (x86)))
     (declare (type (signed-byte 49) ptr))
     (declare (xargs :guard (and (integerp ptr)
                                 (<= (- *2^47*) ptr)
                                 (<= ptr *2^47*)
                                 (nat-listp acc))))
     (let ((__function__ 'read-memory-zero-terminated))
       (declare (ignorable __function__))
       (if
        (signed-byte-p 48 ptr)
        (b* (((mv flg (the (unsigned-byte 8) mem-val)
                  x86)
              (rml08 ptr :r x86))
             ((when flg) (mv flg acc x86)))
          (if (equal 0 mem-val)
              (mv nil (append (reverse acc) '(0)) x86)
            (read-memory-zero-terminated (the (signed-byte 49) (1+ ptr))
                                         x86 (cons mem-val acc))))
        (mv t (reverse acc) x86))))

    Theorem: byte-listp-mv-nth-1-read-memory-zero-terminated

    (defthm byte-listp-mv-nth-1-read-memory-zero-terminated
     (implies
        (and (x86p x86) (byte-listp acc))
        (byte-listp (mv-nth 1
                            (read-memory-zero-terminated ptr x86 acc))))
     :rule-classes :type-prescription)

    Theorem: x86p-mv-nth-2-read-memory-zero-terminated

    (defthm x86p-mv-nth-2-read-memory-zero-terminated
      (implies
           (x86p x86)
           (x86p (mv-nth 2
                         (read-memory-zero-terminated ptr x86 acc)))))