• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Community
    • Std
    • 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
            • Read-operands-and-write-results
            • Effective-address-computations
            • Select-operand-size
            • Instruction-pointer-operations
            • Stack-pointer-operations
            • Select-segment-register
            • Prefix-modrm-sib-decoding
              • Modr/m-decoding
                • Modr/m-structures
                  • Modr/m
                    • !modr/m->r/m
                    • !modr/m->reg
                    • !modr/m->mod
                      • Modr/m-p
                      • Modr/m->reg
                      • Modr/m->mod
                      • Modr/m-fix
                      • Modr/m->r/m
                    • Modr/m-equiv-under-mask
                    • Modr/m-debug
                  • Three-byte-opcode-modr/m-p
                  • 64-bit-mode-0f-3a-three-byte-opcode-modr/m-p
                  • 64-bit-mode-0f-38-three-byte-opcode-modr/m-p
                  • 32-bit-mode-0f-3a-three-byte-opcode-modr/m-p
                  • 32-bit-mode-0f-38-three-byte-opcode-modr/m-p
                  • 64-bit-mode-two-byte-opcode-modr/m-p
                  • 32-bit-mode-two-byte-opcode-modr/m-p
                  • Two-byte-opcode-modr/m-p
                  • Show-no-modr/m-insts
                  • 64-bit-mode-one-byte-opcode-modr/m-p
                  • 32-bit-mode-one-byte-opcode-modr/m-p
                  • Vex-opcode-modr/m-p
                  • One-byte-opcode-modr/m-p
                • Mandatory-prefixes-computation
                • Modr/m-detection
                • Legacy-prefixes-decoding
                • Compute-mandatory-prefix-for-three-byte-opcode
                • 64-bit-compute-mandatory-prefix-for-0f-3a-three-byte-opcode
                • 64-bit-compute-mandatory-prefix-for-0f-38-three-byte-opcode
                • 32-bit-compute-mandatory-prefix-for-0f-3a-three-byte-opcode
                • 32-bit-compute-mandatory-prefix-for-0f-38-three-byte-opcode
                • 64-bit-compute-mandatory-prefix-for-two-byte-opcode
                • 32-bit-compute-mandatory-prefix-for-two-byte-opcode
                • Instructions-with-mandatory-prefixes
                • Compute-mandatory-prefix-for-0f-3a-three-byte-opcode
                • Compute-mandatory-prefix-for-0f-38-three-byte-opcode
                • Compute-mandatory-prefix-for-two-byte-opcode
              • Select-address-size
              • Rex-byte-from-vex-prefixes
              • Check-instruction-length
              • Error-objects
              • Rip-guard-okp
              • Sib-decoding
            • Instructions
            • Register-readers-and-writers
            • X86-modes
            • Segmentation
            • Other-non-deterministic-computations
            • Environment
            • Paging
          • Implemented-opcodes
          • To-do
          • Proof-utilities
          • Peripherals
          • Model-validation
          • Modelcalls
          • Concrete-simulation-examples
          • Utils
          • Debugging-code-proofs
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Modr/m

    !modr/m->mod

    Update the |COMMON-LISP|::|MOD| field of a modr/m bit structure.

    Signature
    (!modr/m->mod mod x) → new-x
    Arguments
    mod — Guard (2bits-p mod).
    x — Guard (modr/m-p x).
    Returns
    new-x — Type (modr/m-p new-x).

    Definitions and Theorems

    Function: !modr/m->mod$inline

    (defun !modr/m->mod$inline (mod x)
     (declare (xargs :guard (and (2bits-p mod) (modr/m-p x))))
     (mbe
        :logic
        (b* ((mod (mbe :logic (2bits-fix mod) :exec mod))
             (x (modr/m-fix x)))
          (part-install mod x :width 2 :low 6))
        :exec (the (unsigned-byte 8)
                   (logior (the (unsigned-byte 8)
                                (logand (the (unsigned-byte 8) x)
                                        (the (signed-byte 9) -193)))
                           (the (unsigned-byte 8)
                                (ash (the (unsigned-byte 2) mod) 6))))))

    Theorem: modr/m-p-of-!modr/m->mod

    (defthm modr/m-p-of-!modr/m->mod
      (b* ((new-x (!modr/m->mod$inline mod x)))
        (modr/m-p new-x))
      :rule-classes :rewrite)

    Theorem: !modr/m->mod$inline-of-2bits-fix-mod

    (defthm !modr/m->mod$inline-of-2bits-fix-mod
      (equal (!modr/m->mod$inline (2bits-fix mod) x)
             (!modr/m->mod$inline mod x)))

    Theorem: !modr/m->mod$inline-2bits-equiv-congruence-on-mod

    (defthm !modr/m->mod$inline-2bits-equiv-congruence-on-mod
      (implies (2bits-equiv mod mod-equiv)
               (equal (!modr/m->mod$inline mod x)
                      (!modr/m->mod$inline mod-equiv x)))
      :rule-classes :congruence)

    Theorem: !modr/m->mod$inline-of-modr/m-fix-x

    (defthm !modr/m->mod$inline-of-modr/m-fix-x
      (equal (!modr/m->mod$inline mod (modr/m-fix x))
             (!modr/m->mod$inline mod x)))

    Theorem: !modr/m->mod$inline-modr/m-equiv-congruence-on-x

    (defthm !modr/m->mod$inline-modr/m-equiv-congruence-on-x
      (implies (modr/m-equiv x x-equiv)
               (equal (!modr/m->mod$inline mod x)
                      (!modr/m->mod$inline mod x-equiv)))
      :rule-classes :congruence)

    Theorem: !modr/m->mod-is-modr/m

    (defthm !modr/m->mod-is-modr/m
      (equal (!modr/m->mod mod x)
             (change-modr/m x :mod mod)))

    Theorem: modr/m->mod-of-!modr/m->mod

    (defthm modr/m->mod-of-!modr/m->mod
      (b* ((?new-x (!modr/m->mod$inline mod x)))
        (equal (modr/m->mod new-x)
               (2bits-fix mod))))

    Theorem: !modr/m->mod-equiv-under-mask

    (defthm !modr/m->mod-equiv-under-mask
      (b* ((?new-x (!modr/m->mod$inline mod x)))
        (modr/m-equiv-under-mask new-x x 63)))