/[movitz]/ia-x86/instr-branch.lisp
ViewVC logotype

Contents of /ia-x86/instr-branch.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Fri Jan 16 11:54:14 2004 UTC (10 years, 3 months ago) by ffjeld
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
Removed non-ASCII characters.
1 ;;;;------------------------------------------------------------------
2 ;;;;
3 ;;;; Copyright (C) 20012000, 2002-2003,
4 ;;;; Department of Computer Science, University of Tromso, Norway
5 ;;;;
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.
11 ;;;;
12 ;;;; $Id: instr-branch.lisp,v 1.2 2004/01/16 11:54:14 ffjeld Exp $
13 ;;;;
14 ;;;;------------------------------------------------------------------
15
16 (in-package "IA-X86-INSTR")
17
18 (defclass branch (instruction) ()) ; superclass for all branch instructions.
19 (defclass conditional-branch (branch) ())
20 (defclass unconditional-branch (branch) ())
21
22 ;;; ----------------------------------------------------------------
23 ;;; JMP [IISR page 11-241]
24 ;;; ----------------------------------------------------------------
25
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)
30
31 (:digit (#xFF 4) 0 (r/m16) :cpu-mode :16-bit)
32 (:digit (#xFF 4) 0 (r/m32) :operand-mode :32-bit)
33
34 (:plain #xEA (2 2) (imm16 displacement) :cpu-mode :16-bit)
35 (:plain #xEA (4 2) (imm16 displacement) :operand-mode :32-bit))
36
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))
40
41
42 ;;; ----------------------------------------------------------------
43 ;;; CALL [IISR page 11-43]
44 ;;; ----------------------------------------------------------------
45
46
47 ;; 16-bit is unusable in 32-bit mode, because EIP is masked by
48 ;; #x0000ffff in this case.
49
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)
53
54 (:digit (#xff 2) 0 (r/m16) :cpu-mode :16-bit)
55 (:digit (#xff 2) 0 (r/m32) :operand-mode :32-bit))
56
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))
61
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))
65
66 ;; TODO
67
68 ;;; ----------------------------------------------------------------
69 ;;; Jcc [IISR page 11-237]
70 ;;; ----------------------------------------------------------------
71
72 (def-instr jcc (conditional-branch))
73
74 (def-instr ja (jcc)
75 (:jcc #x77)
76 (:jcc2 #x87))
77 (def-instr jae (jcc)
78 (:jcc #x73)
79 (:jcc2 #x83))
80 (def-instr jb (jcc)
81 (:jcc #x72)
82 (:jcc2 #x82))
83 (def-instr jbe (jcc)
84 (:jcc #x76)
85 (:jcc2 #x86))
86 (def-instr jc (jcc)
87 (:jcc #x72 :priority -10)
88 (:jcc2 #x82 :priority -10))
89 (def-instr jcxz (jcc)
90 (:jcc #xe3 :operand-mode :16-bit))
91 (def-instr jecxz (jcc)
92 (:jcc #xe3 :operand-mode :32-bit))
93 (def-instr je (jcc)
94 (:jcc #x74)
95 (:jcc2 #x84))
96 (def-instr jg (jcc)
97 (:jcc #x7f)
98 (:jcc2 #x8f))
99 (def-instr jge (jcc)
100 (:jcc #x7d)
101 (:jcc2 #x8d))
102 (def-instr jl (jcc)
103 (:jcc #x7c)
104 (:jcc2 #x8c))
105 (def-instr jle (jcc)
106 (:jcc #x7e)
107 (:jcc2 #x8e))
108 (def-instr jna (jcc)
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))
114 (def-instr jnb (jcc)
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))
120 (def-instr jnc (jcc)
121 (:jcc #x73 :priority -10)
122 (:jcc2 #x83 :priority -10))
123 (def-instr jne (jcc)
124 (:jcc #x75)
125 (:jcc2 #x85))
126 (def-instr jng (jcc)
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))
132 (def-instr jnl (jcc)
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))
138 (def-instr jno (jcc)
139 (:jcc #x71)
140 (:jcc2 #x81))
141 (def-instr jnp (jcc)
142 (:jcc #x7b)
143 (:jcc2 #x8b))
144 (def-instr jns (jcc)
145 (:jcc #x79)
146 (:jcc2 #x89))
147 (def-instr jnz (jcc)
148 (:jcc #x75 :priority -10)
149 (:jcc2 #x85 :priority -10))
150 (def-instr jo (jcc)
151 (:jcc #x70)
152 (:jcc2 #x80))
153 (def-instr jp (jcc)
154 (:jcc #x7a)
155 (:jcc2 #x8a))
156 (def-instr jpe (jcc)
157 (:jcc #x7a :priority -10)
158 (:jcc2 #x8a :priority -10))
159 (def-instr jpo (jcc)
160 (:jcc #x7b :priority -10)
161 (:jcc2 #x8b :priority -10))
162 (def-instr js (jcc)
163 (:jcc #x78)
164 (:jcc2 #x88))
165 (def-instr jz (jcc)
166 (:jcc #x74 :priority -10)
167 (:jcc2 #x84 :priority -10))
168
169 ;;; ----------------------------------------------------------------
170 ;;; LOOP [IISR page 11-273]
171 ;;; ----------------------------------------------------------------
172
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)))
176
177 ;;; ----------------------------------------------------------------
178 ;;; Misc. branch related instructions
179 ;;; ----------------------------------------------------------------
180
181 (def-instr leave (instruction) (:simple #xc9))
182 (def-instr enter (instruction) (:plain #xC8 (0 3) (imm16-8 imm8-0)))
183
184 (def-instr iret (unconditional-branch) (:simple #xcf :operand-mode :16-bit))
185 (def-instr iretd (unconditional-branch) (:simple #xcf :operand-mode :32-bit))
186
187 (def-instr ret (unconditional-branch)
188 (:plain #xC3 (0 0) ())
189 (:plain #xC2 (0 2) (imm16)))
190
191 (def-instr lret (unconditional-branch)
192 (:plain #xCB (0 0) ())
193 (:plain #xCA (0 2) (imm16)))
194

  ViewVC Help
Powered by ViewVC 1.1.5