Decoder and dispatch function for two-byte opcodes
(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
Function:
(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:
(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))))