one_byte_opcodes.isa revision 4369:5b1ad8322f0e
111986Sandreas.sandberg@arm.com// Copyright (c) 2007 The Hewlett-Packard Development Company 211986Sandreas.sandberg@arm.com// All rights reserved. 311986Sandreas.sandberg@arm.com// 411986Sandreas.sandberg@arm.com// Redistribution and use of this software in source and binary forms, 511986Sandreas.sandberg@arm.com// with or without modification, are permitted provided that the 611986Sandreas.sandberg@arm.com// following conditions are met: 711986Sandreas.sandberg@arm.com// 811986Sandreas.sandberg@arm.com// The software must be used only for Non-Commercial Use which means any 911986Sandreas.sandberg@arm.com// use which is NOT directed to receiving any direct monetary 1012037Sandreas.sandberg@arm.com// compensation for, or commercial advantage from such use. Illustrative 1112037Sandreas.sandberg@arm.com// examples of non-commercial use are academic research, personal study, 1212037Sandreas.sandberg@arm.com// teaching, education and corporate research & development. 1312037Sandreas.sandberg@arm.com// Illustrative examples of commercial use are distributing products for 1412037Sandreas.sandberg@arm.com// commercial advantage and providing services using the software for 1512391Sjason@lowepower.com// commercial advantage. 1612391Sjason@lowepower.com// 1712391Sjason@lowepower.com// If you wish to use this software or functionality therein that may be 1812391Sjason@lowepower.com// covered by patents for commercial use, please contact: 1912391Sjason@lowepower.com// Director of Intellectual Property Licensing 2012391Sjason@lowepower.com// Office of Strategy and Technology 2111986Sandreas.sandberg@arm.com// Hewlett-Packard Company 2211986Sandreas.sandberg@arm.com// 1501 Page Mill Road 2311986Sandreas.sandberg@arm.com// Palo Alto, California 94304 2411986Sandreas.sandberg@arm.com// 2511986Sandreas.sandberg@arm.com// Redistributions of source code must retain the above copyright notice, 2611986Sandreas.sandberg@arm.com// this list of conditions and the following disclaimer. Redistributions 2711986Sandreas.sandberg@arm.com// in binary form must reproduce the above copyright notice, this list of 2811986Sandreas.sandberg@arm.com// conditions and the following disclaimer in the documentation and/or 2911986Sandreas.sandberg@arm.com// other materials provided with the distribution. Neither the name of 3011986Sandreas.sandberg@arm.com// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its 3111986Sandreas.sandberg@arm.com// contributors may be used to endorse or promote products derived from 3211986Sandreas.sandberg@arm.com// this software without specific prior written permission. No right of 3311986Sandreas.sandberg@arm.com// sublicense is granted herewith. Derivatives of the software and 3411986Sandreas.sandberg@arm.com// output created using the software may be prepared, but only for 3511986Sandreas.sandberg@arm.com// Non-Commercial Uses. Derivatives of the software may be shared with 3611986Sandreas.sandberg@arm.com// others provided: (i) the others agree to abide by the list of 3711986Sandreas.sandberg@arm.com// conditions herein which includes the Non-Commercial Use restrictions; 3811986Sandreas.sandberg@arm.com// and (ii) such Derivatives of the software include the above copyright 3911986Sandreas.sandberg@arm.com// notice to acknowledge the contribution from this software where 4011986Sandreas.sandberg@arm.com// applicable, this list of conditions and the disclaimer below. 4111986Sandreas.sandberg@arm.com// 4212391Sjason@lowepower.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4311986Sandreas.sandberg@arm.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 4412391Sjason@lowepower.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 4512391Sjason@lowepower.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 4612391Sjason@lowepower.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4712391Sjason@lowepower.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 4812391Sjason@lowepower.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 4912391Sjason@lowepower.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 5011986Sandreas.sandberg@arm.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 5112391Sjason@lowepower.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 5211986Sandreas.sandberg@arm.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 5311986Sandreas.sandberg@arm.com// 5411986Sandreas.sandberg@arm.com// Authors: Gabe Black 5511986Sandreas.sandberg@arm.com 5611986Sandreas.sandberg@arm.com//////////////////////////////////////////////////////////////////// 5711986Sandreas.sandberg@arm.com// 5812391Sjason@lowepower.com// Decode the one byte opcodes 5911986Sandreas.sandberg@arm.com// 6011986Sandreas.sandberg@arm.com 6111986Sandreas.sandberg@arm.com0x1: decode OPCODE_OP_TOP5 { 6211986Sandreas.sandberg@arm.com format WarnUnimpl { 6311986Sandreas.sandberg@arm.com 0x00: decode OPCODE_OP_BOTTOM3 { 6411986Sandreas.sandberg@arm.com 0x4: Inst::ADD(rAl,Ib); 6511986Sandreas.sandberg@arm.com 0x5: Inst::ADD(rAx,Iz); 6611986Sandreas.sandberg@arm.com 0x6: push_ES(); 6711986Sandreas.sandberg@arm.com 0x7: pop_ES(); 6811986Sandreas.sandberg@arm.com default: MultiInst::ADD(OPCODE_OP_BOTTOM3, 6911986Sandreas.sandberg@arm.com [Eb,Gb],[Ev,Gv],[Gb,Eb],[Gv,Ev]); 7011986Sandreas.sandberg@arm.com } 7111986Sandreas.sandberg@arm.com 0x01: decode OPCODE_OP_BOTTOM3 { 7211986Sandreas.sandberg@arm.com 0x0: or_Eb_Gb(); 7311986Sandreas.sandberg@arm.com 0x1: or_Ev_Gv(); 7411986Sandreas.sandberg@arm.com 0x2: or_Gb_Eb(); 7511986Sandreas.sandberg@arm.com 0x3: or_Gv_Ev(); 7611986Sandreas.sandberg@arm.com 0x4: or_Al_Ib(); 7711986Sandreas.sandberg@arm.com 0x5: or_rAX_Iz(); 7811986Sandreas.sandberg@arm.com 0x6: push_CS(); 7912391Sjason@lowepower.com //Any time this is seen, it should generate a two byte opcode 8011986Sandreas.sandberg@arm.com 0x7: M5InternalError::error( 8111986Sandreas.sandberg@arm.com {{"Saw a one byte opcode whose value was 0x0F!"}}); 8211986Sandreas.sandberg@arm.com } 8311986Sandreas.sandberg@arm.com 0x02: decode OPCODE_OP_BOTTOM3 { 8411986Sandreas.sandberg@arm.com 0x0: adc_Eb_Gb(); 8511986Sandreas.sandberg@arm.com 0x1: adc_Ev_Gv(); 8611986Sandreas.sandberg@arm.com 0x2: adc_Gb_Eb(); 8712037Sandreas.sandberg@arm.com 0x3: adc_Gv_Ev(); 8812037Sandreas.sandberg@arm.com 0x4: adc_Al_Ib(); 8912037Sandreas.sandberg@arm.com 0x5: adc_rAX_Iz(); 9012037Sandreas.sandberg@arm.com 0x6: push_SS(); 9112037Sandreas.sandberg@arm.com 0x7: pop_SS(); 9212037Sandreas.sandberg@arm.com } 9311986Sandreas.sandberg@arm.com 0x03: decode OPCODE_OP_BOTTOM3 { 9411986Sandreas.sandberg@arm.com 0x0: sbb_Eb_Gb(); 9511986Sandreas.sandberg@arm.com 0x1: sbb_Ev_Gv(); 9612391Sjason@lowepower.com 0x2: sbb_Gb_Eb(); 9712391Sjason@lowepower.com 0x3: sbb_Gv_Ev(); 9812391Sjason@lowepower.com 0x4: sbb_Al_Ib(); 9912391Sjason@lowepower.com 0x5: sbb_rAX_Iz(); 10012391Sjason@lowepower.com 0x6: push_DS(); 10112391Sjason@lowepower.com 0x7: pop_DS(); 10212391Sjason@lowepower.com } 10312037Sandreas.sandberg@arm.com 0x04: decode OPCODE_OP_BOTTOM3 { 10412391Sjason@lowepower.com 0x0: and_Eb_Gb(); 10512391Sjason@lowepower.com 0x1: and_Ev_Gv(); 10612391Sjason@lowepower.com 0x2: and_Gb_Eb(); 10712391Sjason@lowepower.com 0x3: and_Gv_Ev(); 10812391Sjason@lowepower.com 0x4: and_Al_Ib(); 10912037Sandreas.sandberg@arm.com 0x5: and_rAX_Iz(); 11012037Sandreas.sandberg@arm.com 0x6: M5InternalError::error( 11112037Sandreas.sandberg@arm.com {{"Tried to execute the ES segment override prefix!"}}); 11212037Sandreas.sandberg@arm.com 0x7: daa(); 11311986Sandreas.sandberg@arm.com } 11412037Sandreas.sandberg@arm.com 0x05: decode OPCODE_OP_BOTTOM3 { 11512391Sjason@lowepower.com 0x0: sub_Eb_Gb(); 11612391Sjason@lowepower.com 0x1: sub_Ev_Gv(); 11712391Sjason@lowepower.com 0x2: sub_Gb_Eb(); 11811986Sandreas.sandberg@arm.com 0x3: sub_Gv_Ev(); 11911986Sandreas.sandberg@arm.com 0x4: sub_Al_Ib(); 12011986Sandreas.sandberg@arm.com 0x5: sub_rAX_Iz(); 12112391Sjason@lowepower.com 0x6: M5InternalError::error( 12211986Sandreas.sandberg@arm.com {{"Tried to execute the CS segment override prefix!"}}); 12311986Sandreas.sandberg@arm.com 0x7: das(); 12411986Sandreas.sandberg@arm.com } 12511986Sandreas.sandberg@arm.com 0x06: decode OPCODE_OP_BOTTOM3 { 12611986Sandreas.sandberg@arm.com 0x4: Inst::XOR(rAl,Ib); 12711986Sandreas.sandberg@arm.com 0x5: Inst::XOR(rAx,Iz); 12812391Sjason@lowepower.com 0x6: M5InternalError::error( 12912391Sjason@lowepower.com {{"Tried to execute the SS segment override prefix!"}}); 13012391Sjason@lowepower.com 0x7: aaa(); 13112391Sjason@lowepower.com default: MultiInst::XOR(OPCODE_OP_BOTTOM3, 13211986Sandreas.sandberg@arm.com [Eb,Gb],[Ev,Gv],[Gb,Eb],[Gv,Ev]); 13311986Sandreas.sandberg@arm.com } 13411986Sandreas.sandberg@arm.com 0x07: decode OPCODE_OP_BOTTOM3 { 13512391Sjason@lowepower.com 0x0: cmp_Eb_Gb(); 13611986Sandreas.sandberg@arm.com 0x1: cmp_Ev_Gv(); 13711986Sandreas.sandberg@arm.com 0x2: cmp_Gb_Eb(); 13811986Sandreas.sandberg@arm.com 0x3: cmp_Gv_Ev(); 13911986Sandreas.sandberg@arm.com 0x4: cmp_Al_Ib(); 14011986Sandreas.sandberg@arm.com 0x5: cmp_rAX_Iz(); 14111986Sandreas.sandberg@arm.com 0x6: M5InternalError::error( 14211986Sandreas.sandberg@arm.com {{"Tried to execute the DS segment override prefix!"}}); 14312391Sjason@lowepower.com 0x7: aas(); 14412391Sjason@lowepower.com } 14512391Sjason@lowepower.com 0x08: decode OPCODE_OP_BOTTOM3 { 14612391Sjason@lowepower.com 0x0: inc_eAX(); 14712391Sjason@lowepower.com 0x1: inc_eCX(); 14812391Sjason@lowepower.com 0x2: inc_eDX(); 14912391Sjason@lowepower.com 0x3: inc_eBX(); 15012391Sjason@lowepower.com 0x4: inc_eSP(); 15112391Sjason@lowepower.com 0x5: inc_eBP(); 15212391Sjason@lowepower.com 0x6: inc_eSI(); 15312391Sjason@lowepower.com 0x7: inc_eDI(); 15411986Sandreas.sandberg@arm.com } 15511986Sandreas.sandberg@arm.com 0x09: decode OPCODE_OP_BOTTOM3 { 156 0x0: dec_eAX(); 157 0x1: dec_eCX(); 158 0x2: dec_eDX(); 159 0x3: dec_eBX(); 160 0x4: dec_eSP(); 161 0x5: dec_eBP(); 162 0x6: dec_eSI(); 163 0x7: dec_eDI(); 164 } 165 0x0A: decode OPCODE_OP_BOTTOM3 { 166 0x0: push_rAX(); 167 0x1: push_rCX(); 168 0x2: push_rDX(); 169 0x3: push_rBX(); 170 0x4: push_rSP(); 171 0x5: push_rBP(); 172 0x6: push_rSI(); 173 0x7: push_rDI(); 174 } 175 0x0B: decode OPCODE_OP_BOTTOM3 { 176 0x0: pop_rAX(); 177 0x1: pop_rCX(); 178 0x2: pop_rDX(); 179 0x3: pop_rBX(); 180 0x4: pop_rSP(); 181 0x5: pop_rBP(); 182 0x6: pop_rSI(); 183 0x7: pop_rDI(); 184 } 185 0x0C: decode OPCODE_OP_BOTTOM3 { 186 0x0: pusha(); 187 0x1: popa(); 188 0x2: bound_Gv_Ma(); 189 0x3: arpl_Ew_Gw(); 190 0x4: M5InternalError::error( 191 {{"Tried to execute the FS segment override prefix!"}}); 192 0x5: M5InternalError::error( 193 {{"Tried to execute the GS segment override prefix!"}}); 194 0x6: M5InternalError::error( 195 {{"Tried to execute the operand size override prefix!"}}); 196 0x7: M5InternalError::error( 197 {{"Tried to execute the DS address size override prefix!"}}); 198 } 199 0x0D: decode OPCODE_OP_BOTTOM3 { 200 0x0: push_Iz(); 201 0x1: imul_Gv_Ev_Iz(); 202 0x2: push_Ib(); 203 0x3: imul_Gv_Ev_Ib(); 204 0x4: ins_Yb_Dx(); 205 0x5: ins_Yz_Dx(); 206 0x6: outs_Dx_Xb(); 207 0x7: outs_Dx_Xz(); 208 } 209 0x0E: decode OPCODE_OP_BOTTOM3 { 210 0x0: jo_Jb(); 211 0x1: jno_Jb(); 212 0x2: jb_Jb(); 213 0x3: jnb_Jb(); 214 0x4: jz_Jb(); 215 0x5: jnz_Jb(); 216 0x6: jbe_Jb(); 217 0x7: jnbe_Jb(); 218 } 219 0x0F: decode OPCODE_OP_BOTTOM3 { 220 0x0: js_Jb(); 221 0x1: jns_Jb(); 222 0x2: jp_Jb(); 223 0x3: jnp_Jb(); 224 0x4: jl_Jb(); 225 0x5: jnl_Jb(); 226 0x6: jle_Jb(); 227 0x7: jnke_Jb(); 228 } 229 0x10: decode OPCODE_OP_BOTTOM3 { 230 0x0: group1_Eb_Ib(); 231 0x1: group1_Ev_Iz(); 232 0x2: group1_Eb_Ib(); 233 0x3: group1_Ev_Ib(); 234 0x4: test_Eb_Gb(); 235 0x5: test_Ev_Gv(); 236 0x6: xchg_Eb_Gb(); 237 0x7: xchg_Ev_Gv(); 238 } 239 0x11: decode OPCODE_OP_BOTTOM3 { 240 0x0: Inst::MOV(); //mov_Eb_Gb(); 241 0x1: Inst::MOV(); //mov_Ev_Gv(); 242 0x2: Inst::MOV(); //mov_Gb_Eb(); 243 0x3: Inst::MOV(); //mov_Gv_Ev(); 244 0x4: Inst::MOV(); //mov_MwRv_Sw(); 245 0x5: lea_Gv_M(); 246 0x6: mov_Sw_MwRv(); 247 0x7: group10_Ev(); //Make sure this is Ev 248 } 249 0x12: decode OPCODE_OP_BOTTOM3 { 250 0x0: nop_or_pause(); //Check for repe prefix 251 0x1: xchg_rCX_rAX(); 252 0x2: xchg_rDX_rAX(); 253 0x3: xchg_rVX_rAX(); 254 0x4: xchg_rSP_rAX(); 255 0x5: xchg_rBP_rAX(); 256 0x6: xchg_rSI_rAX(); 257 0x7: xchg_rDI_rAX(); 258 } 259 0x13: decode OPCODE_OP_BOTTOM3 { 260 0x0: cbw_or_cwde_or_cdqe_rAX(); 261 0x1: cwd_or_cdq_or_cqo_rAX_rDX(); 262 0x2: call_Ap(); 263 0x3: fwait(); //aka wait 264 0x4: pushf_Fv(); 265 0x5: popf_Fv(); 266 0x6: sahf(); 267 0x7: lahf(); 268 } 269 0x14: decode OPCODE_OP_BOTTOM3 { 270 0x0: mov_Al_Ob(); 271 0x1: mov_rAX_Ov(); 272 0x2: mov_Ob_Al(); 273 0x3: mov_Ov_rAX(); 274 0x4: movs_Yb_Xb(); 275 0x5: movs_Yv_Xv(); 276 0x6: cmps_Yb_Xb(); 277 0x7: cmps_Yv_Xv(); 278 } 279 0x15: decode OPCODE_OP_BOTTOM3 { 280 0x0: test_Al_Ib(); 281 0x1: test_rAX_Iz(); 282 0x2: stos_Yb_Al(); 283 0x3: stos_Yv_rAX(); 284 0x4: lods_Al_Xb(); 285 0x5: lods_rAX_Xv(); 286 0x6: scas_Yb_Al(); 287 0x7: scas_Yv_rAX(); 288 } 289 0x16: decode OPCODE_OP_BOTTOM3 { 290 0x0: mov_Al_Ib(); 291 0x1: mov_Cl_Ib(); 292 0x2: mov_Dl_Ib(); 293 0x3: mov_Bl_Ib(); 294 0x4: mov_Ah_Ib(); 295 0x5: mov_Ch_Ib(); 296 0x6: mov_Dh_Ib(); 297 0x7: mov_Bh_Ib(); 298 } 299 0x17: decode OPCODE_OP_BOTTOM3 { 300 0x0: mov_rAX_Iv(); 301 0x1: mov_rCX_Iv(); 302 0x2: mov_rDX_Iv(); 303 0x3: mov_rBX_Iv(); 304 0x4: mov_rSP_Iv(); 305 0x5: mov_rBP_Iv(); 306 0x6: mov_rSI_Iv(); 307 0x7: mov_rDI_Iv(); 308 } 309 0x18: decode OPCODE_OP_BOTTOM3 { 310 0x0: group2_Eb_Ib(); 311 0x1: group2_Ev_Ib(); 312 0x2: ret_near_Iw(); 313 0x3: ret_near(); 314 0x4: les_Gz_Mp(); 315 0x5: lds_Gz_Mp(); 316 0x6: group12_Eb_Ib(); 317 0x7: group12_Ev_Iz(); 318 } 319 0x19: decode OPCODE_OP_BOTTOM3 { 320 0x0: enter_Iw_Ib(); 321 0x1: leave(); 322 0x2: ret_far_Iw(); 323 0x3: ret_far(); 324 0x4: int3(); 325 0x5: int_Ib(); 326 0x6: into(); 327 0x7: iret(); 328 } 329 0x1A: decode OPCODE_OP_BOTTOM3 { 330 0x0: group2_Eb_1(); 331 0x1: group2_Ev_1(); 332 0x2: group2_Eb_Cl(); 333 0x3: group2_Ev_Cl(); 334 0x4: aam_Ib(); 335 0x5: aad_Ib(); 336 0x6: salc(); 337 0x7: xlat(); 338 } 339 0x1B: decode OPCODE_OP_BOTTOM3 { 340 0x0: esc0(); 341 0x1: esc1(); 342 0x2: esc2(); 343 0x3: esc3(); 344 0x4: esc4(); 345 0x5: esc5(); 346 0x6: esc6(); 347 0x7: esc7(); 348 } 349 0x1C: decode OPCODE_OP_BOTTOM3 { 350 0x0: loopne_Jb(); 351 0x1: loope_Jb(); 352 0x2: loop_Jb(); 353 0x3: jcxz_or_jecx_or_jrcx(); 354 0x4: in_Al_Ib(); 355 0x5: in_eAX_Ib(); 356 0x6: out_Ib_Al(); 357 0x7: out_Ib_eAX(); 358 } 359 0x1D: decode OPCODE_OP_BOTTOM3 { 360 0x0: call_Jz(); 361 0x1: jmp_Jz(); 362 0x2: jmp_Ap(); 363 0x3: jmp_Jb(); 364 0x4: in_Al_Dx(); 365 0x5: in_eAX_Dx(); 366 0x6: out_Dx_Al(); 367 0x7: out_Dx_eAX(); 368 } 369 0x1E: decode OPCODE_OP_BOTTOM3 { 370 0x0: M5InternalError::error( 371 {{"Tried to execute the lock prefix!"}}); 372 0x1: int1(); 373 0x2: M5InternalError::error( 374 {{"Tried to execute the repne prefix!"}}); 375 0x3: M5InternalError::error( 376 {{"Tried to execute the rep/repe prefix!"}}); 377 0x4: hlt(); 378 0x5: cmc(); 379 0x6: group3_Eb(); 380 0x7: group3_Ev(); 381 } 382 0x1F: decode OPCODE_OP_BOTTOM3 { 383 0x0: clc(); 384 0x1: stc(); 385 0x2: cli(); 386 0x3: sti(); 387 0x4: cld(); 388 0x5: std(); 389 0x6: group4(); 390 0x7: group5(); 391 } 392 } 393 default: FailUnimpl::oneByteOps(); 394} 395