• 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
              • Simd-sub-spec
              • Simd-add-spec
              • Imul-spec
              • Mul-spec
              • Idiv-spec
              • Div-spec
              • Shrd-spec
              • Shld-spec
                • Shld-spec-64
                • Shld-spec-32
                • Shld-spec-16
                • 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
    • Shld-spec

    Shld-spec-16

    Signature
    (shld-spec-16 dst src cnt input-rflags) 
      → 
    (mv output-dst undefined-dst? output-rflags undefined-flags)
    Arguments
    cnt — Note that cnt is masked appropriately by the caller of this function.

    Definitions and Theorems

    Function: shld-spec-16

    (defun shld-spec-16 (dst src cnt input-rflags)
     (declare (type (unsigned-byte 16) dst)
              (type (unsigned-byte 16) src)
              (type (unsigned-byte 6) cnt)
              (type (unsigned-byte 32) input-rflags))
     (let ((__function__ 'shld-spec-16))
      (declare (ignorable __function__))
      (b*
       ((dst (mbe :logic (n-size 16 dst) :exec dst))
        (src (mbe :logic (n-size 16 src) :exec src))
        (cnt (mbe :logic (n-size 6 cnt) :exec cnt))
        (input-rflags (mbe :logic (n32 input-rflags)
                           :exec input-rflags))
        (dst-src
             (the (unsigned-byte 32)
                  (logior (the (unsigned-byte 32)
                               (ash (the (unsigned-byte 16) dst) 16))
                          (the (unsigned-byte 16) src))))
        (output-dst
            (the (unsigned-byte 16)
                 (n-size 16
                         (logtail 16
                                  (ash (the (unsigned-byte 32) dst-src)
                                       (the (unsigned-byte 16) cnt))))))
        ((mv (the (unsigned-byte 32) output-rflags)
             (the (unsigned-byte 32)
                  undefined-flags))
         (case cnt
          (0 (mv input-rflags 0))
          (1
           (b*
            ((cf
              (mbe
               :logic (part-select dst :low 15 :width 1)
               :exec
               (the (unsigned-byte 1)
                    (logand (the (unsigned-byte 16)
                                 (ash (the (unsigned-byte 16) dst) -15))
                            1))))
             (of (if (= (logbit 15 dst)
                        (logbit 15 output-dst))
                     0
                   1))
             (pf (general-pf-spec 16 output-dst))
             (zf (zf-spec output-dst))
             (sf (general-sf-spec 16 output-dst))
             (output-rflags
              (mbe
               :logic (change-rflagsbits input-rflags
                                         :cf cf
                                         :of of
                                         :pf pf
                                         :zf zf
                                         :sf sf)
               :exec
               (the
                (unsigned-byte 32)
                (!rflagsbits->cf
                 cf
                 (!rflagsbits->of
                      of
                      (!rflagsbits->pf
                           pf
                           (!rflagsbits->zf
                                zf
                                (!rflagsbits->sf sf input-rflags))))))))
             (undefined-flags (the (unsigned-byte 32)
                                   (!rflagsbits->af 1 0))))
            (mv output-rflags undefined-flags)))
          (otherwise
           (if
            (<= cnt 16)
            (b*
             ((cf
               (mbe
                 :logic (part-select dst
                                     :low (- 16 cnt)
                                     :width 1)
                 :exec
                 (logand 1
                         (the (unsigned-byte 16)
                              (ash (the (unsigned-byte 16) dst)
                                   (the (signed-byte 7) (- cnt 16)))))))
              (pf (general-pf-spec 16 output-dst))
              (zf (zf-spec output-dst))
              (sf (general-sf-spec 16 output-dst))
              (output-rflags
               (mbe
                :logic (change-rflagsbits input-rflags
                                          :cf cf
                                          :pf pf
                                          :zf zf
                                          :sf sf)
                :exec
                (the
                  (unsigned-byte 32)
                  (!rflagsbits->cf
                       cf
                       (!rflagsbits->pf
                            pf
                            (!rflagsbits->zf
                                 zf
                                 (!rflagsbits->sf sf input-rflags)))))))
              (undefined-flags
                 (mbe :logic (change-rflagsbits 0 :af 1 :of 1)
                      :exec (!rflagsbits->af 1 (!rflagsbits->of 1 0)))))
             (mv output-rflags undefined-flags))
            (b*
             ((output-rflags input-rflags)
              (undefined-flags
               (the
                (unsigned-byte 32)
                (!rflagsbits->cf
                 1
                 (!rflagsbits->of
                  1
                  (!rflagsbits->pf
                      1
                      (!rflagsbits->zf
                           1
                           (!rflagsbits->sf
                                1
                                (!rflagsbits->af 1 input-rflags)))))))))
             (mv output-rflags undefined-flags))))))
        (output-rflags (mbe :logic (n32 output-rflags)
                            :exec output-rflags))
        (undefined-flags (mbe :logic (n32 undefined-flags)
                              :exec undefined-flags)))
       (mv output-dst (> cnt 16)
           output-rflags undefined-flags))))

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

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

    Theorem: booleanp-mv-nth-1-shld-spec-16

    (defthm booleanp-mv-nth-1-shld-spec-16
      (booleanp (mv-nth 1
                        (shld-spec-16 dst src cnt input-rflags))))

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

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

    Theorem: mv-nth-3-shld-spec-16

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