• 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
            • Converting-between-strings-and-bytes
            • Writing-strings-or-bytes-to-memory
              • Write-bytes-to-memory
                • Write-string-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
    • Writing-strings-or-bytes-to-memory

    Write-bytes-to-memory

    The byte at the smallest address should be the last byte of bytes.

    Signature
    (write-bytes-to-memory ptr bytes x86) → (mv flg x86)
    Returns
    x86 — Type (x86p x86), given (x86p x86).

    Definitions and Theorems

    Function: write-bytes-to-memory

    (defun write-bytes-to-memory (ptr bytes x86)
      (declare (xargs :stobjs (x86)))
      (declare (type (signed-byte 49) ptr))
      (declare (xargs :guard (and (integerp ptr)
                                  (<= (- *2^47*) ptr)
                                  (byte-listp bytes)
                                  (< (+ -1 (len bytes) ptr) *2^47*))
                      :split-types t))
      (let ((__function__ 'write-bytes-to-memory))
        (declare (ignorable __function__))
        (if (mbt (and (integerp ptr)
                      (<= (- *2^47*) ptr)
                      (byte-listp bytes)
                      (< (+ -1 (len bytes) ptr) *2^47*)))
            (if (endp bytes)
                (mv nil x86)
              (b* (((mv flg x86)
                    (wml08 ptr (the (unsigned-byte 8) (car bytes))
                           x86))
                   ((when flg) (mv flg x86)))
                (write-bytes-to-memory (the (signed-byte 49) (1+ ptr))
                                       (cdr bytes)
                                       x86)))
          (mv t x86))))

    Theorem: x86p-of-write-bytes-to-memory.x86

    (defthm x86p-of-write-bytes-to-memory.x86
      (implies (x86p x86)
               (b* (((mv ?flg ?x86)
                     (write-bytes-to-memory ptr bytes x86)))
                 (x86p x86)))
      :rule-classes :rewrite)

    Theorem: rewrite-write-bytes-to-memory-to-wb

    (defthm rewrite-write-bytes-to-memory-to-wb
      (implies
           (and (app-view x86)
                (canonical-address-p (+ -1 (len bytes) addr))
                (canonical-address-p addr)
                (byte-listp bytes))
           (and (equal (mv-nth 0
                               (write-bytes-to-memory addr bytes x86))
                       (mv-nth 0
                               (wb (len bytes)
                                   addr :w (combine-bytes bytes)
                                   x86)))
                (equal (mv-nth 1
                               (write-bytes-to-memory addr bytes x86))
                       (mv-nth 1
                               (wb (len bytes)
                                   addr :w (combine-bytes bytes)
                                   x86))))))