[movitz-cvs] CVS movitz
ffjeld
ffjeld at common-lisp.net
Wed Feb 27 21:22:47 UTC 2008
Update of /project/movitz/cvsroot/movitz
In directory clnet:/tmp/cvs-serv661
Modified Files:
asm-x86.lisp
Log Message:
Add disassembler for opcode-reg-imm.
--- /project/movitz/cvsroot/movitz/asm-x86.lisp 2008/02/27 20:55:50 1.32
+++ /project/movitz/cvsroot/movitz/asm-x86.lisp 2008/02/27 21:22:47 1.33
@@ -6,7 +6,7 @@
;;;; Author: Frode Vatvedt Fjeld <frodef at acm.org>
;;;; Distribution: See the accompanying file COPYING.
;;;;
-;;;; $Id: asm-x86.lisp,v 1.32 2008/02/27 20:55:50 ffjeld Exp $
+;;;; $Id: asm-x86.lisp,v 1.33 2008/02/27 21:22:47 ffjeld Exp $
;;;;
;;;;------------------------------------------------------------------
@@ -217,7 +217,8 @@
(cond
((atom body)
nil)
- ((member (car body) '(reg-modrm modrm opcode imm-modrm imm opcode-reg pc-rel moffset sreg-modrm))
+ ((member (car body) '(reg-modrm modrm opcode imm-modrm imm opcode-reg
+ opcode-reg-imm pc-rel moffset sreg-modrm))
(list body))
(t (mapcan #'find-forms body)))))
(let ((defun-name (intern (format nil "~A-~A" 'instruction-encoder operator))))
@@ -899,6 +900,15 @@
:extra extra-operand))
code))
+(defun decode-opcode-reg-imm (code operator opcode operand-size address-size rex operand-ordering imm-type)
+ (declare (ignore address-size rex))
+ (values (list* operator
+ (order-operands operand-ordering
+ :reg (nth (ldb (byte 3 0) opcode)
+ (register-set-by-mode operand-size))
+ :imm (code-call (decode-integer code imm-type))))
+ code))
+
(defun decode-reg-modrm-16 (code operand-size)
(let* ((modrm (pop-code code mod/rm))
(mod (ldb (byte 2 6) modrm))
@@ -1259,8 +1269,18 @@
(t default-rex))))))))))
(defmacro opcode-reg-imm (opcode op-reg op-imm type)
- `(return-when
- (encode-opcode-reg-imm operator legacy-prefixes ,opcode ,op-reg ,op-imm ',type operator-mode default-rex)))
+ `(progn
+ (assembler
+ (return-when
+ (encode-opcode-reg-imm operator legacy-prefixes ,opcode ,op-reg ,op-imm ',type operator-mode default-rex)))
+ (disassembler
+ (loop for reg from #b000 to #b111
+ do (define-disassembler (operator (logior ,opcode reg) operator-mode)
+ decode-opcode-reg-imm
+ (operand-ordering operand-formals
+ :reg ',op-reg
+ :imm ',op-imm)
+ ',type)))))
(defmacro far-pointer (opcode segment offset offset-type &rest extra)
`(when (and (immediate-p ,segment)
More information about the Movitz-cvs
mailing list