• 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
            • Read-operands-and-write-results
            • Effective-address-computations
              • X86-effective-addr-32/64
              • X86-effective-addr-from-sib
              • X86-effective-addr-16
              • X86-effective-addr-16-disp
              • X86-effective-addr
              • Select-operand-size
              • Instruction-pointer-operations
              • Stack-pointer-operations
              • Select-segment-register
              • Prefix-modrm-sib-decoding
              • 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
    • Effective-address-computations

    X86-effective-addr

    Effective address calculation.

    Signature
    (x86-effective-addr proc-mode p4 temp-rip 
                        rex-byte r/m mod sib num-imm-bytes x86) 
     
      → 
    (mv flg i64p-memory-address increment-rip-by x86)
    Arguments
    rex-byte — Rex byte.
    r/m — r/m field of ModR/M byte.
    mod — mod field of ModR/M byte.
    sib — Sib byte.
    num-imm-bytes — Number of immediate bytes (0, 1, 2, or 4) that follow the sib (or displacement bytes, if any).
    Returns
    x86 — Type (x86p x86), given (force (x86p x86)).

    This is a wrapper that calls x86-effective-addr-16 or x86-effective-addr-32/64 based on the address size.

    Definitions and Theorems

    Function: x86-effective-addr

    (defun x86-effective-addr
           (proc-mode p4 temp-rip
                      rex-byte r/m mod sib num-imm-bytes x86)
      (declare (xargs :stobjs (x86)))
      (declare (type (integer 0 4) proc-mode)
               (type (signed-byte 48) temp-rip)
               (type (unsigned-byte 8) rex-byte)
               (type (unsigned-byte 3) r/m)
               (type (unsigned-byte 2) mod)
               (type (unsigned-byte 8) sib)
               (type (unsigned-byte 3) num-imm-bytes))
      (declare (xargs :guard (and (2bits-p mod)
                                  (3bits-p r/m)
                                  (sib-p sib))))
      (let ((__function__ 'x86-effective-addr))
        (declare (ignorable __function__))
        (if (eql 2
                 (select-address-size proc-mode (if p4 t nil)
                                      x86))
            (x86-effective-addr-16 proc-mode temp-rip r/m mod x86)
          (x86-effective-addr-32/64 proc-mode p4 temp-rip rex-byte
                                    r/m mod sib num-imm-bytes x86))))

    Theorem: x86p-of-x86-effective-addr.x86

    (defthm x86p-of-x86-effective-addr.x86
     (implies (force (x86p x86))
              (b* (((mv ?flg ?i64p-memory-address
                        ?increment-rip-by ?x86)
                    (x86-effective-addr proc-mode p4 temp-rip rex-byte
                                        r/m mod sib num-imm-bytes x86)))
                (x86p x86)))
     :rule-classes :rewrite)

    Theorem: i64p-mv-nth-1-x86-effective-addr

    (defthm i64p-mv-nth-1-x86-effective-addr
     (signed-byte-p
          64
          (mv-nth 1
                  (x86-effective-addr proc-mode p4 temp-rip rex-byte
                                      r/m mod sib num-imm-bytes x86)))
     :rule-classes
     (:rewrite
      (:type-prescription
       :corollary
       (integerp
            (mv-nth 1
                    (x86-effective-addr proc-mode p4 temp-rip rex-byte
                                        r/m mod sib num-imm-bytes x86)))
       :hints (("Goal" :in-theory '(signed-byte-p integer-range-p))))
      (:linear
       :corollary
       (and
        (<= -9223372036854775808
            (mv-nth 1
                    (x86-effective-addr proc-mode p4 temp-rip rex-byte
                                        r/m mod sib num-imm-bytes x86)))
        (<
         (mv-nth
            1
            (x86-effective-addr proc-mode p4 temp-rip
                                rex-byte r/m mod sib num-imm-bytes x86))
         9223372036854775808))
       :hints
       (("Goal"
             :in-theory '(signed-byte-p integer-range-p (:e expt)))))))

    Theorem: natp-mv-nth-2-x86-effective-addr

    (defthm natp-mv-nth-2-x86-effective-addr
      (natp (mv-nth 2
                    (x86-effective-addr proc-mode p4 temp-rip rex-byte
                                        r/m mod sib num-imm-bytes x86)))
      :rule-classes :type-prescription)

    Theorem: mv-nth-2-x86-effective-addr-<=-4

    (defthm mv-nth-2-x86-effective-addr-<=-4
     (<=
       (mv-nth
            2
            (x86-effective-addr proc-mode p4 temp-rip
                                rex-byte r/m mod sib num-imm-bytes x86))
       4)
     :rule-classes :linear)

    Theorem: x86-effective-addr-when-64-bit-modep

    (defthm x86-effective-addr-when-64-bit-modep
      (equal (x86-effective-addr 0 p4 temp-rip
                                 rex-byte r/m mod sib num-imm-bytes x86)
             (x86-effective-addr-32/64 0 p4 temp-rip rex-byte
                                       r/m mod sib num-imm-bytes x86)))