• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
          • Instructions
            • Two-byte-opcodes
            • One-byte-opcodes
            • Fp-opcodes
            • Instruction-semantic-functions
              • Sar-spec
              • Shr-spec
              • Sal/shl-spec
              • Rol-spec
              • Ror-spec
              • Rcl-spec
              • Rcr-spec
                • Rcr-spec-64
                • Rcr-spec-32
                • Rcr-spec-16
                  • Rcr-spec-8
                • Simd-sub-spec
                • Simd-add-spec
                • Imul-spec
                • Mul-spec
                • Idiv-spec
                • Div-spec
                • Shrd-spec
                • Shld-spec
                • Gpr-arith/logic-spec
                • Shrx-spec
                • Shlx-spec
                • Sarx-spec
                • Floating-point-specifications
              • X86-illegal-instruction
              • Implemented-opcodes
              • Opcode-maps
              • X86-general-protection
              • X86-device-not-available
              • X86-step-unimplemented
              • Privileged-opcodes
              • Three-byte-opcodes
            • 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
    • Rcr-spec

    Rcr-spec-16

    Signature
    (rcr-spec-16 dst src input-rflags) → (mv * * *)
    Arguments
    src — Note that src is masked appropriately by the caller of this function.

    Definitions and Theorems

    Function: rcr-spec-16

    (defun rcr-spec-16 (dst src input-rflags)
     (declare (type (unsigned-byte 16) dst)
              (type (unsigned-byte 6) src)
              (type (unsigned-byte 32) input-rflags))
     (let ((__function__ 'rcr-spec-16))
      (declare (ignorable __function__))
      (b*
       ((dst (mbe :logic (n-size 16 dst) :exec dst))
        (src (mbe :logic (n-size 6 src) :exec src))
        (input-rflags (mbe :logic (n32 input-rflags)
                           :exec input-rflags))
        (input-cf (the (unsigned-byte 1)
                       (rflagsbits->cf input-rflags)))
        (new-dst (mbe :logic (part-install input-cf dst
                                           :low 16
                                           :width 1)
                      :exec (the (unsigned-byte 17)
                                 (logior (the (unsigned-byte 17)
                                              (ash input-cf 16))
                                         dst))))
        (raw-result (the (unsigned-byte 17)
                         (fast-rotate-right new-dst 17 src)))
        (result (the (unsigned-byte 16)
                     (n-size 16 raw-result)))
        ((mv (the (unsigned-byte 32) output-rflags)
             (the (unsigned-byte 32)
                  undefined-flags))
         (case src
          (0 (mv input-rflags 0))
          (1
           (b*
            ((cf
              (mbe :logic (logbit 16 raw-result)
                   :exec
                   (logand 1
                           (the (unsigned-byte 1)
                                (ash (the (unsigned-byte 17) raw-result)
                                     -16)))))
             (of
              (b-xor
               (mbe
                 :logic (logbit 15 result)
                 :exec (logand 1
                               (the (unsigned-byte 1)
                                    (ash (the (unsigned-byte 16) result)
                                         -15))))
               (mbe
                 :logic (part-select result :low 14 :width 1)
                 :exec (logand 1
                               (the (unsigned-byte 2)
                                    (ash (the (unsigned-byte 16) result)
                                         -14))))))
             (output-rflags
              (mbe
               :logic (change-rflagsbits input-rflags
                                         :cf cf
                                         :of of)
               :exec
               (the
                 (unsigned-byte 32)
                 (!rflagsbits->cf cf
                                  (!rflagsbits->of of input-rflags))))))
            (mv output-rflags 0)))
          (otherwise
           (b*
            ((cf
              (mbe
               :logic (logbit 16 raw-result)
               :exec
               (the
                   (unsigned-byte 1)
                   (logand 1
                           (the (unsigned-byte 1)
                                (ash (the (unsigned-byte 17) raw-result)
                                     -16))))))
             (output-rflags (the (unsigned-byte 32)
                                 (!rflagsbits->cf cf input-rflags)))
             (undefined-flags (the (unsigned-byte 32)
                                   (!rflagsbits->of 1 0))))
            (mv output-rflags undefined-flags))))))
       (mv result output-rflags undefined-flags))))

    Theorem: n16-mv-nth-0-rcr-spec-16

    (defthm n16-mv-nth-0-rcr-spec-16
     (unsigned-byte-p 16
                      (mv-nth 0 (rcr-spec-16 dst src output-rflags)))
     :rule-classes
     (:rewrite
      (:type-prescription
        :corollary (natp (mv-nth 0 (rcr-spec-16 dst src output-rflags)))
        :hints
        (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp))))
      (:linear
       :corollary
       (and (<= 0
                (mv-nth 0 (rcr-spec-16 dst src output-rflags)))
            (< (mv-nth 0 (rcr-spec-16 dst src output-rflags))
               65536))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))

    Theorem: mv-nth-1-rcr-spec-16

    (defthm mv-nth-1-rcr-spec-16
     (unsigned-byte-p 32
                      (mv-nth 1 (rcr-spec-16 dst src output-rflags)))
     :rule-classes
     (:rewrite
      (:type-prescription
        :corollary (natp (mv-nth 1 (rcr-spec-16 dst src output-rflags)))
        :hints
        (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp))))
      (:linear
       :corollary
       (and (<= 0
                (mv-nth 1 (rcr-spec-16 dst src output-rflags)))
            (< (mv-nth 1 (rcr-spec-16 dst src output-rflags))
               4294967296))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))

    Theorem: mv-nth-2-rcr-spec-16

    (defthm mv-nth-2-rcr-spec-16
     (unsigned-byte-p 32
                      (mv-nth 2 (rcr-spec-16 dst src output-rflags)))
     :rule-classes
     (:rewrite
      (:type-prescription
        :corollary (natp (mv-nth 2 (rcr-spec-16 dst src output-rflags)))
        :hints
        (("Goal" :in-theory '(unsigned-byte-p integer-range-p natp))))
      (:linear
       :corollary
       (and (<= 0
                (mv-nth 2 (rcr-spec-16 dst src output-rflags)))
            (< (mv-nth 2 (rcr-spec-16 dst src output-rflags))
               4294967296))
       :hints
       (("Goal"
            :in-theory '(unsigned-byte-p integer-range-p (:e expt)))))))