• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Debugging
    • Projects
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
      • X86isa
        • Program-execution
        • Introduction
        • X86isa-build-instructions
        • Publications
        • Contributors
        • Machine
          • Syscalls
          • Cpuid
          • X86isa-state
          • Linear-memory
          • Rflag-specifications
          • Characterizing-undefined-behavior
          • Top-level-memory
          • App-view
          • X86-decoder
          • Physical-memory
          • Decoding-and-spec-utils
          • Instructions
          • X86-modes
          • Segmentation
          • Register-readers-and-writers
          • 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
        • Proof-utilities
        • To-do
        • Concrete-simulation-examples
        • Model-validation
        • Utils
        • Debugging-code-proofs
      • Axe
      • Execloader
    • Testing-utilities
    • Math
  • Environment

Writing-strings-or-bytes-to-memory

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))))))

Function: write-string-to-memory

(defun write-string-to-memory (ptr str x86)
  (declare (xargs :stobjs (x86)))
  (declare (type (signed-byte 49) ptr))
  (declare (xargs :guard (and (stringp str)
                              (integerp ptr)
                              (<= (- *2^47*) ptr)
                              (< (+ -1 ptr (length str)) *2^47*))
                  :split-types t))
  (let ((__function__ 'write-string-to-memory))
    (declare (ignorable __function__))
    (let ((bytes (string-to-bytes str)))
      (write-bytes-to-memory ptr bytes x86))))

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

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

Subtopics

Write-bytes-to-memory
The byte at the smallest address should be the last byte of bytes.
Write-string-to-memory