Commit e0f2c6f4 authored by Frode Vatvedt Fjeld's avatar Frode Vatvedt Fjeld

Fix disassembly of pc-rel and far-pointer.

parent 08a28e7f
......@@ -6,7 +6,7 @@
;;;; Author: Frode Vatvedt Fjeld <>
;;;; Distribution: See the accompanying file COPYING.
;;;; $Id: asm-x86.lisp,v 1.35 2008/02/28 20:30:09 ffjeld Exp $
;;;; $Id: asm-x86.lisp,v 1.36 2008/02/28 20:33:06 ffjeld Exp $
......@@ -941,14 +941,14 @@
(ecase mod
(case r/m
(#b110 (code-call (decode-integer code '(uint 16))))
(#b110 (list (code-call (decode-integer code '(uint 16)))))
(t (operands r/m))))
(append (operands r/m)
(code-call (decode-integer code '(sint 8)))))
(list (code-call (decode-integer code '(sint 8))))))
(append (operands r/m)
(code-call (decode-integer code '(uint 16))))))))
(list (code-call (decode-integer code '(uint 16)))))))))
(defun decode-reg-modrm-32 (code operand-size)
......@@ -1088,12 +1088,12 @@
(assert (= code-size (length code)))
(append extra-prefixes code))))))))))
(defmacro pc-rel (opcode operand type &rest extras)
(defmacro pc-rel (opcode operand type &optional (mode 'operator-mode) &rest extras)
(return-when (encode-pc-rel operator legacy-prefixes ,opcode ,operand ',type ,@extras)))
(define-disassembler (operator ,opcode operator-mode)
(define-disassembler (operator ,opcode ,mode)
......@@ -1313,7 +1313,7 @@
:imm ',op-imm)
(defmacro far-pointer (opcode segment offset offset-type &rest extra)
(defmacro far-pointer (opcode segment offset offset-type &optional mode &rest extra)
(when (and (immediate-p ,segment)
......@@ -1327,7 +1327,7 @@
(encode-integer segment '(uint 16)))
(define-disassembler (operator ,opcode operator-mode)
(define-disassembler (operator ,opcode ,(or mode 'operator-mode))
......@@ -1728,9 +1728,9 @@
(when (or (and (eq *cpu-mode* :32-bit)
(eq *cpu-mode* :16-bit))
(pc-rel ,opcode2 dst (sint 16)
(pc-rel ,opcode2 dst (sint 16) nil
:operand-size :16-bit))
(pc-rel ,opcode2 dst (sint 32)
(pc-rel ,opcode2 dst (sint 32) nil
:operand-size (case *cpu-mode*
((:16-bit :32-bit)
......@@ -1768,7 +1768,7 @@
(define-jcc :jz #x74)
(define-operator* (:16 :jcxz :32 :jecxz :64 :jrcxz) (dst)
(pc-rel #xe3 dst (sint 8)
(pc-rel #xe3 dst (sint 8) nil
:operand-size operator-mode
:rex default-rex))
......@@ -1778,16 +1778,16 @@
(when (eq *cpu-mode* :16-bit)
(far-pointer #xea seg-dst dst (uint 16)))
(far-pointer #xea seg-dst dst (uint 16) :16-bit))
(when (eq *cpu-mode* :32-bit)
(far-pointer #xea seg-dst dst (xint 32))))
(far-pointer #xea seg-dst dst (xint 32) :32-bit)))
(t (let ((dst seg-dst))
(pc-rel #xeb dst (sint 8))
(when (or (and (eq *cpu-mode* :32-bit)
(eq *cpu-mode* :16-bit))
(pc-rel #xe9 dst (sint 16)))
(pc-rel #xe9 dst (sint 32))
(pc-rel #xe9 dst (sint 16) :16-bit))
(pc-rel #xe9 dst (sint 32) :32-bit)
(when (or (not *position-independent-p*)
(indirect-operand-p dst))
(let ((operator-mode :32-bit))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment