• 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-bytes-from-memory

    Read nbytes bytes from memory

    Signature
    (read-bytes-from-memory ptr nbytes 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-bytes-from-memory

    (defun read-bytes-from-memory (ptr nbytes x86 acc)
     (declare (xargs :stobjs (x86)))
     (declare (type (signed-byte 49) ptr)
              (type (unsigned-byte 48) nbytes))
     (declare (xargs :split-types t
                     :guard (and (integerp nbytes)
                                 (<= 0 nbytes)
                                 (integerp ptr)
                                 (<= (- *2^47*) ptr)
                                 (< (+ ptr nbytes) *2^47*)
                                 (nat-listp acc))))
     (let ((__function__ 'read-bytes-from-memory))
       (declare (ignorable __function__))
       (if
        (mbt (and (integerp nbytes)
                  (integerp ptr)
                  (<= (- *2^47*) ptr)
                  (< (+ ptr nbytes) *2^47*)))
        (if (zp nbytes)
            (mv nil (reverse acc) x86)
          (b* (((mv flg (the (unsigned-byte 8) byte)
                    x86)
                (rml08 ptr :r x86))
               ((when flg) (mv flg nil x86)))
            (read-bytes-from-memory (the (signed-byte 49) (1+ ptr))
                                    (the (unsigned-byte 48) (1- nbytes))
                                    x86 (cons byte acc))))
        (mv t (reverse acc) x86))))

    Theorem: byte-listp-mv-nth-1-read-bytes-from-memory

    (defthm byte-listp-mv-nth-1-read-bytes-from-memory
     (implies
      (forced-and (x86p x86) (byte-listp acc))
      (byte-listp (mv-nth 1
                          (read-bytes-from-memory ptr nbytes x86 acc))))
     :rule-classes :type-prescription)

    Theorem: x86p-mv-nth-2-read-bytes-from-memory

    (defthm x86p-mv-nth-2-read-bytes-from-memory
      (implies
           (x86p x86)
           (x86p (mv-nth 2
                         (read-bytes-from-memory ptr nbytes x86 acc)))))