1 ;;;;------------------------------------------------------------------
3 ;;;; Copyright (C) 20012000, 2002-2003,
4 ;;;; Department of Computer Science, University of Tromso, Norway
6 ;;;; Filename: instr-branch.lisp
7 ;;;; Description: Branch instructions.
8 ;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
9 ;;;; Created at: Tue Feb 1 15:05:51 2000
10 ;;;; Distribution: See the accompanying file COPYING.
12 ;;;; $Id: instr-branch.lisp,v 1.2 2004/01/16 11:54:14 ffjeld Exp $
14 ;;;;------------------------------------------------------------------
16 (in-package "IA-X86-INSTR")
18 (defclass branch
(instruction) ()) ; superclass for all branch instructions.
19 (defclass conditional-branch
(branch) ())
20 (defclass unconditional-branch
(branch) ())
22 ;;; ----------------------------------------------------------------
23 ;;; JMP [IISR page 11-241]
24 ;;; ----------------------------------------------------------------
26 (def-instr jmp
(unconditional-branch)
27 (:plain
#xEB
(1 0) (rel8))
28 (:plain
#xE9
(2 0) (rel16) :cpu-mode
:16-bit
)
29 (:plain
#xE9
(4 0) (rel32) :operand-mode
:32-bit
)
31 (:digit
(#xFF
4) 0 (r/m16
) :cpu-mode
:16-bit
)
32 (:digit
(#xFF
4) 0 (r/m32
) :operand-mode
:32-bit
)
34 (:plain
#xEA
(2 2) (imm16 displacement
) :cpu-mode
:16-bit
)
35 (:plain
#xEA
(4 2) (imm16 displacement
) :operand-mode
:32-bit
))
37 (def-instr jmp-segment
(unconditional-branch)
38 (:digit
(#xff
5) 0 (r/m16
) :cpu-mode
:16-bit
)
39 (:digit
(#xff
5) 0 (r/m32
) :operand-mode
:32-bit
))
42 ;;; ----------------------------------------------------------------
43 ;;; CALL [IISR page 11-43]
44 ;;; ----------------------------------------------------------------
47 ;; 16-bit is unusable in 32-bit mode, because EIP is masked by
48 ;; #x0000ffff in this case.
50 (def-instr call
(branch) ; conditional, unconditional, or not a branch at all??
51 (:plain
#xe8
(2 0) (rel16) :cpu-mode
:16-bit
)
52 (:plain
#xe8
(4 0) (rel32) :operand-mode
:32-bit
)
54 (:digit
(#xff
2) 0 (r/m16
) :cpu-mode
:16-bit
)
55 (:digit
(#xff
2) 0 (r/m32
) :operand-mode
:32-bit
))
57 ;; (:plain calls #x9A (4 0) (ptr16-16) :operand-mode :16-bit)
58 ;; (:plain #x9A (6 0) (ptr16-32) :operand-mode :32-bit)
59 ;; (:digit calls (#xFF 3) 0 (m16-16) :operand-mode :16-bit)
60 ;; (:digit (#xFF 3) 0 (m16-32) :operand-mode :32-bit))
62 (def-instr call-segment
(branch)
63 (:digit
(#xff
3) 0 (r/m16
) :cpu-mode
:16-bit
)
64 (:digit
(#xff
3) 0 (r/m32
) :operand-mode
:32-bit
))
68 ;;; ----------------------------------------------------------------
69 ;;; Jcc [IISR page 11-237]
70 ;;; ----------------------------------------------------------------
72 (def-instr jcc
(conditional-branch))
87 (:jcc
#x72
:priority -
10)
88 (:jcc2
#x82
:priority -
10))
90 (:jcc
#xe3
:operand-mode
:16-bit
))
91 (def-instr jecxz
(jcc)
92 (:jcc
#xe3
:operand-mode
:32-bit
))
109 (:jcc
#x76
:priority -
10)
110 (:jcc2
#x86
:priority -
10))
111 (def-instr jnae
(jcc)
112 (:jcc
#x72
:priority -
10)
113 (:jcc2
#x82
:priority -
10))
115 (:jcc
#x73
:priority -
10)
116 (:jcc2
#x83
:priority -
10))
117 (def-instr jnbe
(jcc)
118 (:jcc
#x77
:priority -
10)
119 (:jcc2
#x87
:priority -
10))
121 (:jcc
#x73
:priority -
10)
122 (:jcc2
#x83
:priority -
10))
127 (:jcc
#x7e
:priority -
10)
128 (:jcc2
#x8e
:priority -
10))
129 (def-instr jnge
(jcc)
130 (:jcc
#x7c
:priority -
10)
131 (:jcc2
#x8c
:priority -
10))
133 (:jcc
#x7d
:priority -
10)
134 (:jcc2
#x8d
:priority -
10))
135 (def-instr jnle
(jcc)
136 (:jcc
#x7f
:priority -
10)
137 (:jcc2
#x8f
:priority -
10))
148 (:jcc
#x75
:priority -
10)
149 (:jcc2
#x85
:priority -
10))
157 (:jcc
#x7a
:priority -
10)
158 (:jcc2
#x8a
:priority -
10))
160 (:jcc
#x7b
:priority -
10)
161 (:jcc2
#x8b
:priority -
10))
166 (:jcc
#x74
:priority -
10)
167 (:jcc2
#x84
:priority -
10))
169 ;;; ----------------------------------------------------------------
170 ;;; LOOP [IISR page 11-273]
171 ;;; ----------------------------------------------------------------
173 (def-instr loop
(conditional-branch) (:plain
#xe2
(1 0) (rel8)))
174 (def-instr loope
(conditional-branch) (:plain
#xe1
(1 0) (rel8)))
175 (def-instr loopne
(conditional-branch) (:plain
#xe0
(1 0) (rel8)))
177 ;;; ----------------------------------------------------------------
178 ;;; Misc. branch related instructions
179 ;;; ----------------------------------------------------------------
181 (def-instr leave
(instruction) (:simple
#xc9
))
182 (def-instr enter
(instruction) (:plain
#xC8
(0 3) (imm16-8 imm8-0
)))
184 (def-instr iret
(unconditional-branch) (:simple
#xcf
:operand-mode
:16-bit
))
185 (def-instr iretd
(unconditional-branch) (:simple
#xcf
:operand-mode
:32-bit
))
187 (def-instr ret
(unconditional-branch)
188 (:plain
#xC3
(0 0) ())
189 (:plain
#xC2
(0 2) (imm16)))
191 (def-instr lret
(unconditional-branch)
192 (:plain
#xCB
(0 0) ())
193 (:plain
#xCA
(0 2) (imm16)))