• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • 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-string-zero-terminated

    Read memory as a string till a zero is encountered

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

    Definitions and Theorems

    Function: read-string-zero-terminated

    (defun read-string-zero-terminated (ptr x86)
      (declare (xargs :stobjs (x86)))
      (declare (type (signed-byte 49) ptr))
      (declare (xargs :guard (and (integerp ptr)
                                  (<= (- *2^47*) ptr)
                                  (<= ptr *2^47*))))
      (let ((__function__ 'read-string-zero-terminated))
        (declare (ignorable __function__))
        (b* (((mv flg bytes x86)
              (read-memory-zero-terminated ptr x86 nil))
             ((when flg) (mv flg "nil" x86))
             (charlist (bytes-to-charlist bytes)))
          (mv nil (coerce charlist 'string)
              x86))))

    Theorem: stringp-mv-nth-1-read-string-zero-terminated

    (defthm stringp-mv-nth-1-read-string-zero-terminated
      (implies (force (x86p x86))
               (stringp (mv-nth 1
                                (read-string-zero-terminated ptr x86))))
      :rule-classes :type-prescription)

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

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