1 //: jump to 8-bit offset
  2 
  3 //:: jump
  4 
  5 :(scenario jump_rel8)
  6 # op  ModRM   SIB   displacement  immediate
  7   eb                05                        # skip 1 instruction
  8   05                              00 00 00 01
  9   05                              00 00 00 02
 10 +run: inst: 0x00000001
 11 +run: jump 5
 12 +run: inst: 0x00000008
 13 -run: inst: 0x00000003
 14 
 15 :(before "End Single-Byte Opcodes")
 16 case 0xeb: {  // jump rel8
 17   int8_t offset = static_cast<int>(next());
 18   trace(2, "run") << "jump " << NUM(offset) << end();
 19   EIP += offset;
 20   break;
 21 }
 22 
 23 //:: jump if equal/zero
 24 
 25 :(scenario je_rel8_success)
 26 % ZF = true;
 27 # op  ModRM   SIB   displacement  immediate
 28   74                05                        # skip 1 instruction
 29   05                              00 00 00 01
 30   05                              00 00 00 02
 31 +run: inst: 0x00000001
 32 +run: jump 5
 33 +run: inst: 0x00000008
 34 -run: inst: 0x00000003
 35 
 36 :(before "End Single-Byte Opcodes")
 37 case 0x74: {  // jump rel8 if ZF
 38   int8_t offset = static_cast<int>(next());
 39   if (ZF) {
 40   ¦ trace(2, "run") << "jump " << NUM(offset) << end();
 41   ¦ EIP += offset;
 42   }
 43   break;
 44 }
 45 
 46 :(scenario je_rel8_fail)
 47 % ZF = false;
 48 # op  ModRM   SIB   displacement  immediate
 49   74                05                        # skip 1 instruction
 50   05                              00 00 00 01
 51   05                              00 00 00 02
 52 +run: inst: 0x00000001
 53 +run: inst: 0x00000003
 54 +run: inst: 0x00000008
 55 -run: jump 5
 56 
 57 //:: jump if not equal/not zero
 58 
 59 :(scenario jne_rel8_success)
 60 % ZF = false;
 61 # op  ModRM   SIB   displacement  immediate
 62   75                05                        # skip 1 instruction
 63   05                              00 00 00 01
 64   05                              00 00 00 02
 65 +run: inst: 0x00000001
 66 +run: jump 5
 67 +run: inst: 0x00000008
 68 -run: inst: 0x00000003
 69 
 70 :(before "End Single-Byte Opcodes")
 71 case 0x75: {  // jump rel8 unless ZF
 72   int8_t offset = static_cast<int>(next());
 73   if (!ZF) {
 74   ¦ trace(2, "run") << "jump " << NUM(offset) << end();
 75   ¦ EIP += offset;
 76   }
 77   break;
 78 }
 79 
 80 :(scenario jne_rel8_fail)
 81 % ZF = true;
 82 # op  ModRM   SIB   displacement  immediate
 83   75                05                        # skip 1 instruction
 84   05                              00 00 00 01
 85   05                              00 00 00 02
 86 +run: inst: 0x00000001
 87 +run: inst: 0x00000003
 88 +run: inst: 0x00000008
 89 -run: jump 5
 90 
 91 //:: jump if greater
 92 
 93 :(scenario jg_rel8_success)
 94 % ZF = false;
 95 % SF = false;
 96 % OF = false;
 97 # op  ModRM   SIB   displacement  immediate
 98   7f                05                        # skip 1 instruction
 99   05                              00 00 00 01
100   05                              00 00 00 02
101 +run: inst: 0x00000001
102 +run: jump 5
103 +run: inst: 0x00000008
104 -run: inst: 0x00000003
105 
106 :(before "End Single-Byte Opcodes")
107 case 0x7f: {  // jump rel8 if !SF and !ZF
108   int8_t offset = static_cast<int>(next());
109   if (!ZF && SF == OF) {
110   ¦ trace(2, "run") << "jump " << NUM(offset) << end();
111   ¦ EIP += offset;
112   }
113   break;
114 }
115 
116 :(scenario jg_rel8_fail)
117 % ZF = false;
118 % SF = true;
119 % OF = false;
120 # op  ModRM   SIB   displacement  immediate
121   7f                05                        # skip 1 instruction
122   05                              00 00 00 01
123   05                              00 00 00 02
124 +run: inst: 0x00000001
125 +run: inst: 0x00000003
126 +run: inst: 0x00000008
127 -run: jump 5
128 
129 //:: jump if greater or equal
130 
131 :(scenario jge_rel8_success)
132 % SF = false;
133 % OF = false;
134 # op  ModRM   SIB   displacement  immediate
135   7d                05                        # skip 1 instruction
136   05                              00 00 00 01
137   05                              00 00 00 02
138 +run: inst: 0x00000001
139 +run: jump 5
140 +run: inst: 0x00000008
141 -run: inst: 0x00000003
142 
143 :(before "End Single-Byte Opcodes")
144 case 0x7d: {  // jump rel8 if !SF
145   int8_t offset = static_cast<int>(next());
146   if (SF == OF) {
147   ¦ trace(2, "run") << "jump " << NUM(offset) << end();
148   ¦ EIP += offset;
149   }
150   break;
151 }
152 
153 :(scenario jge_rel8_fail)
154 % SF = true;
155 % OF = false;
156 # op  ModRM   SIB   displacement  immediate
157   7d                05                        # skip 1 instruction
158   05                              00 00 00 01
159   05                              00 00 00 02
160 +run: inst: 0x00000001
161 +run: inst: 0x00000003
162 +run: inst: 0x00000008
163 -run: jump 5
164 
165 //:: jump if lesser
166 
167 :(scenario jl_rel8_success)
168 % ZF = false;
169 % SF = true;
170 % OF = false;
171 # op  ModRM   SIB   displacement  immediate
172   7c                05                        # skip 1 instruction
173   05                              00 00 00 01
174   05                              00 00 00 02
175 +run: inst: 0x00000001
176 +run: jump 5
177 +run: inst: 0x00000008
178 -run: inst: 0x00000003
179 
180 :(before "End Single-Byte Opcodes")
181 case 0x7c: {  // jump rel8 if SF and !ZF
182   int8_t offset = static_cast<int>(next());
183   if (SF != OF) {
184   ¦ trace(2, "run") << "jump " << NUM(offset) << end();
185   ¦ EIP += offset;
186   }
187   break;
188 }
189 
190 :(scenario jl_rel8_fail)
191 % ZF = false;
192 % SF = false;
193 % OF = false;
194 # op  ModRM   SIB   displacement  immediate
195   7c                05                        # skip 1 instruction
196   05                              00 00 00 01
197   05                              00 00 00 02
198 +run: inst: 0x00000001
199 +run: inst: 0x00000003
200 +run: inst: 0x00000008
201 -run: jump 5
202 
203 //:: jump if lesser or equal
204 
205 :(scenario jle_rel8_equal)
206 % ZF = true;
207 % SF = false;
208 % OF = false;
209 # op  ModRM   SIB   displacement  immediate
210   7e                05                        # skip 1 instruction
211   05                              00 00 00 01
212   05                              00 00 00 02
213 +run: inst: 0x00000001
214 +run: jump 5
215 +run: inst: 0x00000008
216 -run: inst: 0x00000003
217 
218 :(scenario jle_rel8_lesser)
219 % ZF = false;
220 % SF = true;
221 % OF = false;
222 # op  ModRM   SIB   displacement  immediate
223   7e                05                        # skip 1 instruction
224   05                              00 00 00 01
225   05                              00 00 00 02
226 +run: inst: 0x00000001
227 +run: jump 5
228 +run: inst: 0x00000008
229 -run: inst: 0x00000003
230 
231 :(before "End Single-Byte Opcodes")
232 case 0x7e: {  // jump rel8 if SF or ZF
233   int8_t offset = static_cast<int>(next());
234   if (ZF || SF != OF) {
235   ¦ trace(2, "run") << "jump " << NUM(offset) << end();
236   ¦ EIP += offset;
237   }
238   break;
239 }
240 
241 :(scenario jle_rel8_greater)
242 % ZF = false;
243 % SF = false;
244 % OF = false;
245 # op  ModRM   SIB   displacement  immediate
246   7e                05                        # skip 1 instruction
247   05                              00 00 00 01
248   05                              00 00 00 02
249 +run: inst: 0x00000001
250 +run: inst: 0x00000003
251 +run: inst: 0x00000008
252 -run: jump 5