one_byte_opcodes.isa revision 4323:13ca4002d2ac
1// Copyright (c) 2007 The Hewlett-Packard Development Company 2// All rights reserved. 3// 4// Redistribution and use of this software in source and binary forms, 5// with or without modification, are permitted provided that the 6// following conditions are met: 7// 8// The software must be used only for Non-Commercial Use which means any 9// use which is NOT directed to receiving any direct monetary 10// compensation for, or commercial advantage from such use. Illustrative 11// examples of non-commercial use are academic research, personal study, 12// teaching, education and corporate research & development. 13// Illustrative examples of commercial use are distributing products for 14// commercial advantage and providing services using the software for 15// commercial advantage. 16// 17// If you wish to use this software or functionality therein that may be 18// covered by patents for commercial use, please contact: 19// Director of Intellectual Property Licensing 20// Office of Strategy and Technology 21// Hewlett-Packard Company 22// 1501 Page Mill Road 23// Palo Alto, California 94304 24// 25// Redistributions of source code must retain the above copyright notice, 26// this list of conditions and the following disclaimer. Redistributions 27// in binary form must reproduce the above copyright notice, this list of 28// conditions and the following disclaimer in the documentation and/or 29// other materials provided with the distribution. Neither the name of 30// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 31// contributors may be used to endorse or promote products derived from 32// this software without specific prior written permission. No right of 33// sublicense is granted herewith. Derivatives of the software and 34// output created using the software may be prepared, but only for 35// Non-Commercial Uses. Derivatives of the software may be shared with 36// others provided: (i) the others agree to abide by the list of 37// conditions herein which includes the Non-Commercial Use restrictions; 38// and (ii) such Derivatives of the software include the above copyright 39// notice to acknowledge the contribution from this software where 40// applicable, this list of conditions and the disclaimer below. 41// 42// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 43// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 44// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 45// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 46// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 47// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 48// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 49// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 50// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 51// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 52// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53// 54// Authors: Gabe Black 55 56//////////////////////////////////////////////////////////////////// 57// 58// Decode the one byte opcodes 59// 60 610x1: decode OPCODE_OP_TOP5 { 62 format WarnUnimpl { 63 0x00: decode OPCODE_OP_BOTTOM3 { 64 0x4: TaggedOp::add({{AddI %0 %0}}, [rAl]); 65 0x5: TaggedOp::add({{AddI %0 %0}}, [rAx]); 66 0x6: push_ES(); 67 0x7: pop_ES(); 68 default: MultiOp::add( 69 {{Add %0 %0 %1}}, 70 OPCODE_OP_BOTTOM3, 71 [[Eb,Gb],[Ev,Gv], 72 [Gb,Eb],[Gv,Ev]]); 73 } 74 0x01: decode OPCODE_OP_BOTTOM3 { 75 0x0: or_Eb_Gb(); 76 0x1: or_Ev_Gv(); 77 0x2: or_Gb_Eb(); 78 0x3: or_Gv_Ev(); 79 0x4: or_Al_Ib(); 80 0x5: or_rAX_Iz(); 81 0x6: push_CS(); 82 //Any time this is seen, it should generate a two byte opcode 83 0x7: M5InternalError::error( 84 {{"Saw a one byte opcode whose value was 0x0F!"}}); 85 } 86 0x02: decode OPCODE_OP_BOTTOM3 { 87 0x0: adc_Eb_Gb(); 88 0x1: adc_Ev_Gv(); 89 0x2: adc_Gb_Eb(); 90 0x3: adc_Gv_Ev(); 91 0x4: adc_Al_Ib(); 92 0x5: adc_rAX_Iz(); 93 0x6: push_SS(); 94 0x7: pop_SS(); 95 } 96 0x03: decode OPCODE_OP_BOTTOM3 { 97 0x0: sbb_Eb_Gb(); 98 0x1: sbb_Ev_Gv(); 99 0x2: sbb_Gb_Eb(); 100 0x3: sbb_Gv_Ev(); 101 0x4: sbb_Al_Ib(); 102 0x5: sbb_rAX_Iz(); 103 0x6: push_DS(); 104 0x7: pop_DS(); 105 } 106 0x04: decode OPCODE_OP_BOTTOM3 { 107 0x0: and_Eb_Gb(); 108 0x1: and_Ev_Gv(); 109 0x2: and_Gb_Eb(); 110 0x3: and_Gv_Ev(); 111 0x4: and_Al_Ib(); 112 0x5: and_rAX_Iz(); 113 0x6: M5InternalError::error( 114 {{"Tried to execute the ES segment override prefix!"}}); 115 0x7: daa(); 116 } 117 0x05: decode OPCODE_OP_BOTTOM3 { 118 0x0: sub_Eb_Gb(); 119 0x1: sub_Ev_Gv(); 120 0x2: sub_Gb_Eb(); 121 0x3: sub_Gv_Ev(); 122 0x4: sub_Al_Ib(); 123 0x5: sub_rAX_Iz(); 124 0x6: M5InternalError::error( 125 {{"Tried to execute the CS segment override prefix!"}}); 126 0x7: das(); 127 } 128 0x06: decode OPCODE_OP_BOTTOM3 { 129 0x4: TaggedOp::xor({{XorI %0 %0}}, [rAl]); 130 0x5: TaggedOp::xor({{XorI %0 %0}}, [rAx]); 131 0x6: M5InternalError::error( 132 {{"Tried to execute the SS segment override prefix!"}}); 133 0x7: aaa(); 134 default: MultiOp::xor( 135 {{Xor %0 %0 %1}}, 136 OPCODE_OP_BOTTOM3, 137 [[Eb,Gb],[Ev,Gv], 138 [Gb,Eb],[Gv,Ev]]); 139 } 140 0x07: decode OPCODE_OP_BOTTOM3 { 141 0x0: cmp_Eb_Gb(); 142 0x1: cmp_Ev_Gv(); 143 0x2: cmp_Gb_Eb(); 144 0x3: cmp_Gv_Ev(); 145 0x4: cmp_Al_Ib(); 146 0x5: cmp_rAX_Iz(); 147 0x6: M5InternalError::error( 148 {{"Tried to execute the DS segment override prefix!"}}); 149 0x7: aas(); 150 } 151 0x08: decode OPCODE_OP_BOTTOM3 { 152 0x0: inc_eAX(); 153 0x1: inc_eCX(); 154 0x2: inc_eDX(); 155 0x3: inc_eBX(); 156 0x4: inc_eSP(); 157 0x5: inc_eBP(); 158 0x6: inc_eSI(); 159 0x7: inc_eDI(); 160 } 161 0x09: decode OPCODE_OP_BOTTOM3 { 162 0x0: dec_eAX(); 163 0x1: dec_eCX(); 164 0x2: dec_eDX(); 165 0x3: dec_eBX(); 166 0x4: dec_eSP(); 167 0x5: dec_eBP(); 168 0x6: dec_eSI(); 169 0x7: dec_eDI(); 170 } 171 0x0A: decode OPCODE_OP_BOTTOM3 { 172 0x0: push_rAX(); 173 0x1: push_rCX(); 174 0x2: push_rDX(); 175 0x3: push_rBX(); 176 0x4: push_rSP(); 177 0x5: push_rBP(); 178 0x6: push_rSI(); 179 0x7: push_rDI(); 180 } 181 0x0B: decode OPCODE_OP_BOTTOM3 { 182 0x0: pop_rAX(); 183 0x1: pop_rCX(); 184 0x2: pop_rDX(); 185 0x3: pop_rBX(); 186 0x4: pop_rSP(); 187 0x5: pop_rBP(); 188 0x6: pop_rSI(); 189 0x7: pop_rDI(); 190 } 191 0x0C: decode OPCODE_OP_BOTTOM3 { 192 0x0: pusha(); 193 0x1: popa(); 194 0x2: bound_Gv_Ma(); 195 0x3: arpl_Ew_Gw(); 196 0x4: M5InternalError::error( 197 {{"Tried to execute the FS segment override prefix!"}}); 198 0x5: M5InternalError::error( 199 {{"Tried to execute the GS segment override prefix!"}}); 200 0x6: M5InternalError::error( 201 {{"Tried to execute the operand size override prefix!"}}); 202 0x7: M5InternalError::error( 203 {{"Tried to execute the DS address size override prefix!"}}); 204 } 205 0x0D: decode OPCODE_OP_BOTTOM3 { 206 0x0: push_Iz(); 207 0x1: imul_Gv_Ev_Iz(); 208 0x2: push_Ib(); 209 0x3: imul_Gv_Ev_Ib(); 210 0x4: ins_Yb_Dx(); 211 0x5: ins_Yz_Dx(); 212 0x6: outs_Dx_Xb(); 213 0x7: outs_Dx_Xz(); 214 } 215 0x0E: decode OPCODE_OP_BOTTOM3 { 216 0x0: jo_Jb(); 217 0x1: jno_Jb(); 218 0x2: jb_Jb(); 219 0x3: jnb_Jb(); 220 0x4: jz_Jb(); 221 0x5: jnz_Jb(); 222 0x6: jbe_Jb(); 223 0x7: jnbe_Jb(); 224 } 225 0x0F: decode OPCODE_OP_BOTTOM3 { 226 0x0: js_Jb(); 227 0x1: jns_Jb(); 228 0x2: jp_Jb(); 229 0x3: jnp_Jb(); 230 0x4: jl_Jb(); 231 0x5: jnl_Jb(); 232 0x6: jle_Jb(); 233 0x7: jnke_Jb(); 234 } 235 0x10: decode OPCODE_OP_BOTTOM3 { 236 0x0: group1_Eb_Ib(); 237 0x1: group1_Ev_Iz(); 238 0x2: group1_Eb_Ib(); 239 0x3: group1_Ev_Ib(); 240 0x4: test_Eb_Gb(); 241 0x5: test_Ev_Gv(); 242 0x6: xchg_Eb_Gb(); 243 0x7: xchg_Ev_Gv(); 244 } 245 0x11: decode OPCODE_OP_BOTTOM3 { 246 0x0: mov_Eb_Gb(); 247 0x1: mov_Ev_Gv(); 248 0x2: mov_Gb_Eb(); 249 0x3: mov_Gv_Ev(); 250 0x4: mov_MwRv_Sw(); 251 0x5: lea_Gv_M(); 252 0x6: mov_Sw_MwRv(); 253 0x7: group10_Ev(); //Make sure this is Ev 254 } 255 0x12: decode OPCODE_OP_BOTTOM3 { 256 0x0: nop_or_pause(); //Check for repe prefix 257 0x1: xchg_rCX_rAX(); 258 0x2: xchg_rDX_rAX(); 259 0x3: xchg_rVX_rAX(); 260 0x4: xchg_rSP_rAX(); 261 0x5: xchg_rBP_rAX(); 262 0x6: xchg_rSI_rAX(); 263 0x7: xchg_rDI_rAX(); 264 } 265 0x13: decode OPCODE_OP_BOTTOM3 { 266 0x0: cbw_or_cwde_or_cdqe_rAX(); 267 0x1: cwd_or_cdq_or_cqo_rAX_rDX(); 268 0x2: call_Ap(); 269 0x3: fwait(); //aka wait 270 0x4: pushf_Fv(); 271 0x5: popf_Fv(); 272 0x6: sahf(); 273 0x7: lahf(); 274 } 275 0x14: decode OPCODE_OP_BOTTOM3 { 276 0x0: mov_Al_Ob(); 277 0x1: mov_rAX_Ov(); 278 0x2: mov_Ob_Al(); 279 0x3: mov_Ov_rAX(); 280 0x4: movs_Yb_Xb(); 281 0x5: movs_Yv_Xv(); 282 0x6: cmps_Yb_Xb(); 283 0x7: cmps_Yv_Xv(); 284 } 285 0x15: decode OPCODE_OP_BOTTOM3 { 286 0x0: test_Al_Ib(); 287 0x1: test_rAX_Iz(); 288 0x2: stos_Yb_Al(); 289 0x3: stos_Yv_rAX(); 290 0x4: lods_Al_Xb(); 291 0x5: lods_rAX_Xv(); 292 0x6: scas_Yb_Al(); 293 0x7: scas_Yv_rAX(); 294 } 295 0x16: decode OPCODE_OP_BOTTOM3 { 296 0x0: mov_Al_Ib(); 297 0x1: mov_Cl_Ib(); 298 0x2: mov_Dl_Ib(); 299 0x3: mov_Bl_Ib(); 300 0x4: mov_Ah_Ib(); 301 0x5: mov_Ch_Ib(); 302 0x6: mov_Dh_Ib(); 303 0x7: mov_Bh_Ib(); 304 } 305 0x17: decode OPCODE_OP_BOTTOM3 { 306 0x0: mov_rAX_Iv(); 307 0x1: mov_rCX_Iv(); 308 0x2: mov_rDX_Iv(); 309 0x3: mov_rBX_Iv(); 310 0x4: mov_rSP_Iv(); 311 0x5: mov_rBP_Iv(); 312 0x6: mov_rSI_Iv(); 313 0x7: mov_rDI_Iv(); 314 } 315 0x18: decode OPCODE_OP_BOTTOM3 { 316 0x0: group2_Eb_Ib(); 317 0x1: group2_Ev_Ib(); 318 0x2: ret_near_Iw(); 319 0x3: ret_near(); 320 0x4: les_Gz_Mp(); 321 0x5: lds_Gz_Mp(); 322 0x6: group12_Eb_Ib(); 323 0x7: group12_Ev_Iz(); 324 } 325 0x19: decode OPCODE_OP_BOTTOM3 { 326 0x0: enter_Iw_Ib(); 327 0x1: leave(); 328 0x2: ret_far_Iw(); 329 0x3: ret_far(); 330 0x4: int3(); 331 0x5: int_Ib(); 332 0x6: into(); 333 0x7: iret(); 334 } 335 0x1A: decode OPCODE_OP_BOTTOM3 { 336 0x0: group2_Eb_1(); 337 0x1: group2_Ev_1(); 338 0x2: group2_Eb_Cl(); 339 0x3: group2_Ev_Cl(); 340 0x4: aam_Ib(); 341 0x5: aad_Ib(); 342 0x6: salc(); 343 0x7: xlat(); 344 } 345 0x1B: decode OPCODE_OP_BOTTOM3 { 346 0x0: esc0(); 347 0x1: esc1(); 348 0x2: esc2(); 349 0x3: esc3(); 350 0x4: esc4(); 351 0x5: esc5(); 352 0x6: esc6(); 353 0x7: esc7(); 354 } 355 0x1C: decode OPCODE_OP_BOTTOM3 { 356 0x0: loopne_Jb(); 357 0x1: loope_Jb(); 358 0x2: loop_Jb(); 359 0x3: jcxz_or_jecx_or_jrcx(); 360 0x4: in_Al_Ib(); 361 0x5: in_eAX_Ib(); 362 0x6: out_Ib_Al(); 363 0x7: out_Ib_eAX(); 364 } 365 0x1D: decode OPCODE_OP_BOTTOM3 { 366 0x0: call_Jz(); 367 0x1: jmp_Jz(); 368 0x2: jmp_Ap(); 369 0x3: jmp_Jb(); 370 0x4: in_Al_Dx(); 371 0x5: in_eAX_Dx(); 372 0x6: out_Dx_Al(); 373 0x7: out_Dx_eAX(); 374 } 375 0x1E: decode OPCODE_OP_BOTTOM3 { 376 0x0: M5InternalError::error( 377 {{"Tried to execute the lock prefix!"}}); 378 0x1: int1(); 379 0x2: M5InternalError::error( 380 {{"Tried to execute the repne prefix!"}}); 381 0x3: M5InternalError::error( 382 {{"Tried to execute the rep/repe prefix!"}}); 383 0x4: hlt(); 384 0x5: cmc(); 385 0x6: group3_Eb(); 386 0x7: group3_Ev(); 387 } 388 0x1F: decode OPCODE_OP_BOTTOM3 { 389 0x0: clc(); 390 0x1: stc(); 391 0x2: cli(); 392 0x3: sti(); 393 0x4: cld(); 394 0x5: std(); 395 0x6: group4(); 396 0x7: group5(); 397 } 398 } 399 default: FailUnimpl::oneByteOps(); 400} 401