• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
    • Projects
    • Debugging
    • 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
            • Get-prefixes
            • Vex-0f3a-execute
            • Vex-0f38-execute
            • Vex-0f-execute
            • Two-byte-opcode-execute
            • Second-three-byte-opcode-execute
            • One-byte-opcode-execute
            • First-three-byte-opcode-execute
            • Evex-0f3a-execute
            • Evex-0f38-execute
            • Evex-0f-execute
            • X86-fetch-decode-execute
            • Vex-decode-and-execute
            • Evex-decode-and-execute
            • Opcode-maps
            • X86-run
            • Implemented-opcodes
            • Three-byte-opcode-decode-and-execute
            • X86-run-halt-count
            • Two-byte-opcode-decode-and-execute
              • X86-run-steps
              • X86-fetch-decode-execute-halt
              • X86-run-halt
              • X86-run-steps1
            • Physical-memory
            • Decoding-and-spec-utils
            • Instructions
            • X86-modes
            • Segmentation
            • Register-readers-and-writers
            • Other-non-deterministic-computations
            • Environment
            • Paging
          • Implemented-opcodes
          • Proof-utilities
          • To-do
          • Concrete-simulation-examples
          • Model-validation
          • Utils
          • Debugging-code-proofs
        • Execloader
        • Axe
      • Testing-utilities
      • Math
    • X86-decoder

    Two-byte-opcode-decode-and-execute

    Decoder and dispatch function for two-byte opcodes

    Signature
    (two-byte-opcode-decode-and-execute 
         proc-mode start-rip temp-rip 
         prefixes rex-byte escape-byte x86) 
     
      → 
    x86

    Source: Intel Manual, Volume 2, Appendix A-2

    Definitions and Theorems

    Function: two-byte-opcode-decode-and-execute

    (defun
     two-byte-opcode-decode-and-execute
     (proc-mode start-rip temp-rip
                prefixes rex-byte escape-byte x86)
     (declare (xargs :stobjs (x86)))
     (declare (type (integer 0 4) proc-mode)
              (type (signed-byte 48) start-rip)
              (type (signed-byte 48) temp-rip)
              (type (unsigned-byte 52) prefixes)
              (type (unsigned-byte 8) rex-byte)
              (type (unsigned-byte 8) escape-byte))
     (declare (xargs :guard (and (prefixes-p prefixes)
                                 (equal escape-byte 15)
                                 (rip-guard-okp proc-mode temp-rip))))
     (let
      ((__function__ 'two-byte-opcode-decode-and-execute))
      (declare (ignorable __function__))
      (b*
       ((ctx 'two-byte-opcode-decode-and-execute)
        ((mv flg0 (the (unsigned-byte 8) opcode)
             x86)
         (rme08 proc-mode temp-rip 1 :x x86))
        ((when flg0)
         (!!ms-fresh :opcode-byte-access-error flg0))
        ((mv flg temp-rip)
         (add-to-*ip proc-mode temp-rip 1 x86))
        ((when flg)
         (!!ms-fresh :increment-error flg))
        ((the (unsigned-byte 8) mandatory-prefix)
         (compute-mandatory-prefix-for-two-byte-opcode
              proc-mode opcode prefixes))
        (modr/m?
           (two-byte-opcode-modr/m-p proc-mode mandatory-prefix opcode))
        ((mv flg1 (the (unsigned-byte 8) modr/m)
             x86)
         (if modr/m?
             (rme08 proc-mode temp-rip 1 :x x86)
             (mv nil 0 x86)))
        ((when flg1)
         (!!ms-fresh :modr/m-byte-read-error flg1))
        ((mv flg temp-rip)
         (if modr/m?
             (add-to-*ip proc-mode temp-rip 1 x86)
             (mv nil temp-rip)))
        ((when flg)
         (!!ms-fresh :increment-error flg))
        (sib?
          (and modr/m?
               (b* ((p4? (eql 103
                              (the (unsigned-byte 8)
                                   (prefixes->adr prefixes))))
                    (16-bit-addressp
                         (eql 2
                              (select-address-size proc-mode p4? x86))))
                   (x86-decode-sib-p modr/m 16-bit-addressp))))
        ((mv flg2 (the (unsigned-byte 8) sib)
             x86)
         (if sib? (rme08 proc-mode temp-rip 1 :x x86)
             (mv nil 0 x86)))
        ((when flg2)
         (!!ms-fresh :sib-byte-read-error flg2))
        ((mv flg temp-rip)
         (if sib?
             (add-to-*ip proc-mode temp-rip 1 x86)
             (mv nil temp-rip)))
        ((when flg)
         (!!ms-fresh :increment-error flg)))
       (two-byte-opcode-execute proc-mode start-rip
                                temp-rip prefixes mandatory-prefix
                                rex-byte opcode modr/m sib x86))))

    Theorem: x86p-two-byte-opcode-decode-and-execute

    (defthm x86p-two-byte-opcode-decode-and-execute
            (implies (x86p x86)
                     (x86p (two-byte-opcode-decode-and-execute
                                proc-mode start-rip temp-rip
                                prefixes rex-byte escape-byte x86))))