1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/classfile/Opcode.java Mon Mar 30 15:08:09 2009 -0700 1.3 @@ -0,0 +1,472 @@ 1.4 +/* 1.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.classfile; 1.30 + 1.31 +import static com.sun.tools.classfile.Instruction.Kind.*; 1.32 +import static com.sun.tools.classfile.Opcode.Set.*; 1.33 + 1.34 +/** 1.35 + * See JVMS3, chapter 6. 1.36 + * 1.37 + * <p>In addition to providing all the standard opcodes defined in JVMS, 1.38 + * this class also provides legacy support for the PicoJava extensions. 1.39 + * 1.40 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 1.41 + * you write code that depends on this, you do so at your own risk. 1.42 + * This code and its internal interfaces are subject to change or 1.43 + * deletion without notice.</b> 1.44 + */ 1.45 +public enum Opcode { 1.46 + NOP(0x0), 1.47 + ACONST_NULL(0x1), 1.48 + ICONST_M1(0x2), 1.49 + ICONST_0(0x3), 1.50 + ICONST_1(0x4), 1.51 + ICONST_2(0x5), 1.52 + ICONST_3(0x6), 1.53 + ICONST_4(0x7), 1.54 + ICONST_5(0x8), 1.55 + LCONST_0(0x9), 1.56 + LCONST_1(0xa), 1.57 + FCONST_0(0xb), 1.58 + FCONST_1(0xc), 1.59 + FCONST_2(0xd), 1.60 + DCONST_0(0xe), 1.61 + DCONST_1(0xf), 1.62 + BIPUSH(0x10, BYTE), 1.63 + SIPUSH(0x11, SHORT), 1.64 + LDC(0x12, CPREF), 1.65 + LDC_W(0x13, CPREF_W), 1.66 + LDC2_W(0x14, CPREF_W), 1.67 + ILOAD(0x15, LOCAL), 1.68 + LLOAD(0x16, LOCAL), 1.69 + FLOAD(0x17, LOCAL), 1.70 + DLOAD(0x18, LOCAL), 1.71 + ALOAD(0x19, LOCAL), 1.72 + ILOAD_0(0x1a), 1.73 + ILOAD_1(0x1b), 1.74 + ILOAD_2(0x1c), 1.75 + ILOAD_3(0x1d), 1.76 + LLOAD_0(0x1e), 1.77 + LLOAD_1(0x1f), 1.78 + LLOAD_2(0x20), 1.79 + LLOAD_3(0x21), 1.80 + FLOAD_0(0x22), 1.81 + FLOAD_1(0x23), 1.82 + FLOAD_2(0x24), 1.83 + FLOAD_3(0x25), 1.84 + DLOAD_0(0x26), 1.85 + DLOAD_1(0x27), 1.86 + DLOAD_2(0x28), 1.87 + DLOAD_3(0x29), 1.88 + ALOAD_0(0x2a), 1.89 + ALOAD_1(0x2b), 1.90 + ALOAD_2(0x2c), 1.91 + ALOAD_3(0x2d), 1.92 + IALOAD(0x2e), 1.93 + LALOAD(0x2f), 1.94 + FALOAD(0x30), 1.95 + DALOAD(0x31), 1.96 + AALOAD(0x32), 1.97 + BALOAD(0x33), 1.98 + CALOAD(0x34), 1.99 + SALOAD(0x35), 1.100 + ISTORE(0x36, LOCAL), 1.101 + LSTORE(0x37, LOCAL), 1.102 + FSTORE(0x38, LOCAL), 1.103 + DSTORE(0x39, LOCAL), 1.104 + ASTORE(0x3a, LOCAL), 1.105 + ISTORE_0(0x3b), 1.106 + ISTORE_1(0x3c), 1.107 + ISTORE_2(0x3d), 1.108 + ISTORE_3(0x3e), 1.109 + LSTORE_0(0x3f), 1.110 + LSTORE_1(0x40), 1.111 + LSTORE_2(0x41), 1.112 + LSTORE_3(0x42), 1.113 + FSTORE_0(0x43), 1.114 + FSTORE_1(0x44), 1.115 + FSTORE_2(0x45), 1.116 + FSTORE_3(0x46), 1.117 + DSTORE_0(0x47), 1.118 + DSTORE_1(0x48), 1.119 + DSTORE_2(0x49), 1.120 + DSTORE_3(0x4a), 1.121 + ASTORE_0(0x4b), 1.122 + ASTORE_1(0x4c), 1.123 + ASTORE_2(0x4d), 1.124 + ASTORE_3(0x4e), 1.125 + IASTORE(0x4f), 1.126 + LASTORE(0x50), 1.127 + FASTORE(0x51), 1.128 + DASTORE(0x52), 1.129 + AASTORE(0x53), 1.130 + BASTORE(0x54), 1.131 + CASTORE(0x55), 1.132 + SASTORE(0x56), 1.133 + POP(0x57), 1.134 + POP2(0x58), 1.135 + DUP(0x59), 1.136 + DUP_X1(0x5a), 1.137 + DUP_X2(0x5b), 1.138 + DUP2(0x5c), 1.139 + DUP2_X1(0x5d), 1.140 + DUP2_X2(0x5e), 1.141 + SWAP(0x5f), 1.142 + IADD(0x60), 1.143 + LADD(0x61), 1.144 + FADD(0x62), 1.145 + DADD(0x63), 1.146 + ISUB(0x64), 1.147 + LSUB(0x65), 1.148 + FSUB(0x66), 1.149 + DSUB(0x67), 1.150 + IMUL(0x68), 1.151 + LMUL(0x69), 1.152 + FMUL(0x6a), 1.153 + DMUL(0x6b), 1.154 + IDIV(0x6c), 1.155 + LDIV(0x6d), 1.156 + FDIV(0x6e), 1.157 + DDIV(0x6f), 1.158 + IREM(0x70), 1.159 + LREM(0x71), 1.160 + FREM(0x72), 1.161 + DREM(0x73), 1.162 + INEG(0x74), 1.163 + LNEG(0x75), 1.164 + FNEG(0x76), 1.165 + DNEG(0x77), 1.166 + ISHL(0x78), 1.167 + LSHL(0x79), 1.168 + ISHR(0x7a), 1.169 + LSHR(0x7b), 1.170 + IUSHR(0x7c), 1.171 + LUSHR(0x7d), 1.172 + IAND(0x7e), 1.173 + LAND(0x7f), 1.174 + IOR(0x80), 1.175 + LOR(0x81), 1.176 + IXOR(0x82), 1.177 + LXOR(0x83), 1.178 + IINC(0x84, LOCAL_BYTE), 1.179 + I2L(0x85), 1.180 + I2F(0x86), 1.181 + I2D(0x87), 1.182 + L2I(0x88), 1.183 + L2F(0x89), 1.184 + L2D(0x8a), 1.185 + F2I(0x8b), 1.186 + F2L(0x8c), 1.187 + F2D(0x8d), 1.188 + D2I(0x8e), 1.189 + D2L(0x8f), 1.190 + D2F(0x90), 1.191 + I2B(0x91), 1.192 + I2C(0x92), 1.193 + I2S(0x93), 1.194 + LCMP(0x94), 1.195 + FCMPL(0x95), 1.196 + FCMPG(0x96), 1.197 + DCMPL(0x97), 1.198 + DCMPG(0x98), 1.199 + IFEQ(0x99, BRANCH), 1.200 + IFNE(0x9a, BRANCH), 1.201 + IFLT(0x9b, BRANCH), 1.202 + IFGE(0x9c, BRANCH), 1.203 + IFGT(0x9d, BRANCH), 1.204 + IFLE(0x9e, BRANCH), 1.205 + IF_ICMPEQ(0x9f, BRANCH), 1.206 + IF_ICMPNE(0xa0, BRANCH), 1.207 + IF_ICMPLT(0xa1, BRANCH), 1.208 + IF_ICMPGE(0xa2, BRANCH), 1.209 + IF_ICMPGT(0xa3, BRANCH), 1.210 + IF_ICMPLE(0xa4, BRANCH), 1.211 + IF_ACMPEQ(0xa5, BRANCH), 1.212 + IF_ACMPNE(0xa6, BRANCH), 1.213 + GOTO(0xa7, BRANCH), 1.214 + JSR(0xa8, BRANCH), 1.215 + RET(0xa9, LOCAL), 1.216 + TABLESWITCH(0xaa, DYNAMIC), 1.217 + LOOKUPSWITCH(0xab, DYNAMIC), 1.218 + IRETURN(0xac), 1.219 + LRETURN(0xad), 1.220 + FRETURN(0xae), 1.221 + DRETURN(0xaf), 1.222 + ARETURN(0xb0), 1.223 + RETURN(0xb1), 1.224 + GETSTATIC(0xb2, CPREF_W), 1.225 + PUTSTATIC(0xb3, CPREF_W), 1.226 + GETFIELD(0xb4, CPREF_W), 1.227 + PUTFIELD(0xb5, CPREF_W), 1.228 + INVOKEVIRTUAL(0xb6, CPREF_W), 1.229 + INVOKESPECIAL(0xb7, CPREF_W), 1.230 + INVOKESTATIC(0xb8, CPREF_W), 1.231 + INVOKEINTERFACE(0xb9, CPREF_W_UBYTE_ZERO), 1.232 + // unused 0xba 1.233 + NEW(0xbb, CPREF_W), 1.234 + NEWARRAY(0xbc, ATYPE), 1.235 + ANEWARRAY(0xbd, CPREF_W), 1.236 + ARRAYLENGTH(0xbe), 1.237 + ATHROW(0xbf), 1.238 + CHECKCAST(0xc0, CPREF_W), 1.239 + INSTANCEOF(0xc1, CPREF_W), 1.240 + MONITORENTER(0xc2), 1.241 + MONITOREXIT(0xc3), 1.242 + // wide 0xc4 1.243 + MULTIANEWARRAY(0xc5, CPREF_W_UBYTE), 1.244 + IFNULL(0xc6, BRANCH), 1.245 + IFNONNULL(0xc7, BRANCH), 1.246 + GOTO_W(0xc8, BRANCH_W), 1.247 + JSR_W(0xc9, BRANCH_W), 1.248 + // impdep 0xfe: PicoJava nonpriv 1.249 + // impdep 0xff: Picojava priv 1.250 + 1.251 + // wide opcodes 1.252 + ILOAD_W(0xc415, WIDE_CPREF_W), 1.253 + LLOAD_W(0xc416, WIDE_CPREF_W), 1.254 + FLOAD_W(0xc417, WIDE_CPREF_W), 1.255 + DLOAD_W(0xc418, WIDE_CPREF_W), 1.256 + ALOAD_W(0xc419, WIDE_CPREF_W), 1.257 + ISTORE_W(0xc436, WIDE_CPREF_W), 1.258 + LSTORE_W(0xc437, WIDE_CPREF_W), 1.259 + FSTORE_W(0xc438, WIDE_CPREF_W), 1.260 + DSTORE_W(0xc439, WIDE_CPREF_W), 1.261 + ASTORE_W(0xc43a, WIDE_CPREF_W), 1.262 + IINC_W(0xc484, WIDE_CPREF_W_SHORT), 1.263 + RET_W(0xc4a9, WIDE_CPREF_W), 1.264 + 1.265 + // PicoJava nonpriv instructions 1.266 + LOAD_UBYTE(PICOJAVA, 0xfe00), 1.267 + LOAD_BYTE(PICOJAVA, 0xfe01), 1.268 + LOAD_CHAR(PICOJAVA, 0xfe02), 1.269 + LOAD_SHORT(PICOJAVA, 0xfe03), 1.270 + LOAD_WORD(PICOJAVA, 0xfe04), 1.271 + RET_FROM_SUB(PICOJAVA, 0xfe05), 1.272 + LOAD_CHAR_OE(PICOJAVA, 0xfe0a), 1.273 + LOAD_SHORT_OE(PICOJAVA, 0xfe0b), 1.274 + LOAD_WORD_OE(PICOJAVA, 0xfe0c), 1.275 + NCLOAD_UBYTE(PICOJAVA, 0xfe10), 1.276 + NCLOAD_BYTE(PICOJAVA, 0xfe11), 1.277 + NCLOAD_CHAR(PICOJAVA, 0xfe12), 1.278 + NCLOAD_SHORT(PICOJAVA, 0xfe13), 1.279 + NCLOAD_WORD(PICOJAVA, 0xfe14), 1.280 + NCLOAD_CHAR_OE(PICOJAVA, 0xfe1a), 1.281 + NCLOAD_SHORT_OE(PICOJAVA, 0xfe1b), 1.282 + NCLOAD_WORD_OE(PICOJAVA, 0xfe1c), 1.283 + CACHE_FLUSH(PICOJAVA, 0xfe1e), 1.284 + STORE_BYTE(PICOJAVA, 0xfe20), 1.285 + STORE_SHORT(PICOJAVA, 0xfe22), 1.286 + STORE_WORD(PICOJAVA, 0xfe24), 1.287 + STORE_SHORT_OE(PICOJAVA, 0xfe2a), 1.288 + STORE_WORD_OE(PICOJAVA, 0xfe2c), 1.289 + NCSTORE_BYTE(PICOJAVA, 0xfe30), 1.290 + NCSTORE_SHORT(PICOJAVA, 0xfe32), 1.291 + NCSTORE_WORD(PICOJAVA, 0xfe34), 1.292 + NCSTORE_SHORT_OE(PICOJAVA, 0xfe3a), 1.293 + NCSTORE_WORD_OE(PICOJAVA, 0xfe3c), 1.294 + ZERO_LINE(PICOJAVA, 0xfe3e), 1.295 + ENTER_SYNC_METHOD(PICOJAVA, 0xfe3f), 1.296 + 1.297 + // PicoJava priv instructions 1.298 + PRIV_LOAD_UBYTE(PICOJAVA, 0xff00), 1.299 + PRIV_LOAD_BYTE(PICOJAVA, 0xff01), 1.300 + PRIV_LOAD_CHAR(PICOJAVA, 0xff02), 1.301 + PRIV_LOAD_SHORT(PICOJAVA, 0xff03), 1.302 + PRIV_LOAD_WORD(PICOJAVA, 0xff04), 1.303 + PRIV_RET_FROM_TRAP(PICOJAVA, 0xff05), 1.304 + PRIV_READ_DCACHE_TAG(PICOJAVA, 0xff06), 1.305 + PRIV_READ_DCACHE_DATA(PICOJAVA, 0xff07), 1.306 + PRIV_LOAD_CHAR_OE(PICOJAVA, 0xff0a), 1.307 + PRIV_LOAD_SHORT_OE(PICOJAVA, 0xff0b), 1.308 + PRIV_LOAD_WORD_OE(PICOJAVA, 0xff0c), 1.309 + PRIV_READ_ICACHE_TAG(PICOJAVA, 0xff0e), 1.310 + PRIV_READ_ICACHE_DATA(PICOJAVA, 0xff0f), 1.311 + PRIV_NCLOAD_UBYTE(PICOJAVA, 0xff10), 1.312 + PRIV_NCLOAD_BYTE(PICOJAVA, 0xff11), 1.313 + PRIV_NCLOAD_CHAR(PICOJAVA, 0xff12), 1.314 + PRIV_NCLOAD_SHORT(PICOJAVA, 0xff13), 1.315 + PRIV_NCLOAD_WORD(PICOJAVA, 0xff14), 1.316 + PRIV_POWERDOWN(PICOJAVA, 0xff16), 1.317 + PRIV_READ_SCACHE_DATA(PICOJAVA, 0xff17), 1.318 + PRIV_NCLOAD_CHAR_OE(PICOJAVA, 0xff1a), 1.319 + PRIV_NCLOAD_SHORT_OE(PICOJAVA, 0xff1b), 1.320 + PRIV_NCLOAD_WORD_OE(PICOJAVA, 0xff1c), 1.321 + PRIV_CACHE_FLUSH(PICOJAVA, 0xff1e), 1.322 + PRIV_CACHE_INDEX_FLUSH(PICOJAVA, 0xff1f), 1.323 + PRIV_STORE_BYTE(PICOJAVA, 0xff20), 1.324 + PRIV_STORE_SHORT(PICOJAVA, 0xff22), 1.325 + PRIV_STORE_WORD(PICOJAVA, 0xff24), 1.326 + PRIV_WRITE_DCACHE_TAG(PICOJAVA, 0xff26), 1.327 + PRIV_WRITE_DCACHE_DATA(PICOJAVA, 0xff27), 1.328 + PRIV_STORE_SHORT_OE(PICOJAVA, 0xff2a), 1.329 + PRIV_STORE_WORD_OE(PICOJAVA, 0xff2c), 1.330 + PRIV_WRITE_ICACHE_TAG(PICOJAVA, 0xff2e), 1.331 + PRIV_WRITE_ICACHE_DATA(PICOJAVA, 0xff2f), 1.332 + PRIV_NCSTORE_BYTE(PICOJAVA, 0xff30), 1.333 + PRIV_NCSTORE_SHORT(PICOJAVA, 0xff32), 1.334 + PRIV_NCSTORE_WORD(PICOJAVA, 0xff34), 1.335 + PRIV_RESET(PICOJAVA, 0xff36), 1.336 + PRIV_WRITE_SCACHE_DATA(PICOJAVA, 0xff37), 1.337 + PRIV_NCSTORE_SHORT_OE(PICOJAVA, 0xff3a), 1.338 + PRIV_NCSTORE_WORD_OE(PICOJAVA, 0xff3c), 1.339 + PRIV_ZERO_LINE(PICOJAVA, 0xff3e), 1.340 + PRIV_READ_REG_0(PICOJAVA, 0xff40), 1.341 + PRIV_READ_REG_1(PICOJAVA, 0xff41), 1.342 + PRIV_READ_REG_2(PICOJAVA, 0xff42), 1.343 + PRIV_READ_REG_3(PICOJAVA, 0xff43), 1.344 + PRIV_READ_REG_4(PICOJAVA, 0xff44), 1.345 + PRIV_READ_REG_5(PICOJAVA, 0xff45), 1.346 + PRIV_READ_REG_6(PICOJAVA, 0xff46), 1.347 + PRIV_READ_REG_7(PICOJAVA, 0xff47), 1.348 + PRIV_READ_REG_8(PICOJAVA, 0xff48), 1.349 + PRIV_READ_REG_9(PICOJAVA, 0xff49), 1.350 + PRIV_READ_REG_10(PICOJAVA, 0xff4a), 1.351 + PRIV_READ_REG_11(PICOJAVA, 0xff4b), 1.352 + PRIV_READ_REG_12(PICOJAVA, 0xff4c), 1.353 + PRIV_READ_REG_13(PICOJAVA, 0xff4d), 1.354 + PRIV_READ_REG_14(PICOJAVA, 0xff4e), 1.355 + PRIV_READ_REG_15(PICOJAVA, 0xff4f), 1.356 + PRIV_READ_REG_16(PICOJAVA, 0xff50), 1.357 + PRIV_READ_REG_17(PICOJAVA, 0xff51), 1.358 + PRIV_READ_REG_18(PICOJAVA, 0xff52), 1.359 + PRIV_READ_REG_19(PICOJAVA, 0xff53), 1.360 + PRIV_READ_REG_20(PICOJAVA, 0xff54), 1.361 + PRIV_READ_REG_21(PICOJAVA, 0xff55), 1.362 + PRIV_READ_REG_22(PICOJAVA, 0xff56), 1.363 + PRIV_READ_REG_23(PICOJAVA, 0xff57), 1.364 + PRIV_READ_REG_24(PICOJAVA, 0xff58), 1.365 + PRIV_READ_REG_25(PICOJAVA, 0xff59), 1.366 + PRIV_READ_REG_26(PICOJAVA, 0xff5a), 1.367 + PRIV_READ_REG_27(PICOJAVA, 0xff5b), 1.368 + PRIV_READ_REG_28(PICOJAVA, 0xff5c), 1.369 + PRIV_READ_REG_29(PICOJAVA, 0xff5d), 1.370 + PRIV_READ_REG_30(PICOJAVA, 0xff5e), 1.371 + PRIV_READ_REG_31(PICOJAVA, 0xff5f), 1.372 + PRIV_WRITE_REG_0(PICOJAVA, 0xff60), 1.373 + PRIV_WRITE_REG_1(PICOJAVA, 0xff61), 1.374 + PRIV_WRITE_REG_2(PICOJAVA, 0xff62), 1.375 + PRIV_WRITE_REG_3(PICOJAVA, 0xff63), 1.376 + PRIV_WRITE_REG_4(PICOJAVA, 0xff64), 1.377 + PRIV_WRITE_REG_5(PICOJAVA, 0xff65), 1.378 + PRIV_WRITE_REG_6(PICOJAVA, 0xff66), 1.379 + PRIV_WRITE_REG_7(PICOJAVA, 0xff67), 1.380 + PRIV_WRITE_REG_8(PICOJAVA, 0xff68), 1.381 + PRIV_WRITE_REG_9(PICOJAVA, 0xff69), 1.382 + PRIV_WRITE_REG_10(PICOJAVA, 0xff6a), 1.383 + PRIV_WRITE_REG_11(PICOJAVA, 0xff6b), 1.384 + PRIV_WRITE_REG_12(PICOJAVA, 0xff6c), 1.385 + PRIV_WRITE_REG_13(PICOJAVA, 0xff6d), 1.386 + PRIV_WRITE_REG_14(PICOJAVA, 0xff6e), 1.387 + PRIV_WRITE_REG_15(PICOJAVA, 0xff6f), 1.388 + PRIV_WRITE_REG_16(PICOJAVA, 0xff70), 1.389 + PRIV_WRITE_REG_17(PICOJAVA, 0xff71), 1.390 + PRIV_WRITE_REG_18(PICOJAVA, 0xff72), 1.391 + PRIV_WRITE_REG_19(PICOJAVA, 0xff73), 1.392 + PRIV_WRITE_REG_20(PICOJAVA, 0xff74), 1.393 + PRIV_WRITE_REG_21(PICOJAVA, 0xff75), 1.394 + PRIV_WRITE_REG_22(PICOJAVA, 0xff76), 1.395 + PRIV_WRITE_REG_23(PICOJAVA, 0xff77), 1.396 + PRIV_WRITE_REG_24(PICOJAVA, 0xff78), 1.397 + PRIV_WRITE_REG_25(PICOJAVA, 0xff79), 1.398 + PRIV_WRITE_REG_26(PICOJAVA, 0xff7a), 1.399 + PRIV_WRITE_REG_27(PICOJAVA, 0xff7b), 1.400 + PRIV_WRITE_REG_28(PICOJAVA, 0xff7c), 1.401 + PRIV_WRITE_REG_29(PICOJAVA, 0xff7d), 1.402 + PRIV_WRITE_REG_30(PICOJAVA, 0xff7e), 1.403 + PRIV_WRITE_REG_31(PICOJAVA, 0xff7f); 1.404 + 1.405 + Opcode(int opcode) { 1.406 + this(STANDARD, opcode, NO_OPERANDS); 1.407 + } 1.408 + 1.409 + Opcode(int opcode, Instruction.Kind kind) { 1.410 + this(STANDARD, opcode, kind); 1.411 + } 1.412 + 1.413 + Opcode(Set set, int opcode) { 1.414 + this(set, opcode, (set == STANDARD ? NO_OPERANDS : WIDE_NO_OPERANDS)); 1.415 + } 1.416 + 1.417 + Opcode(Set set, int opcode, Instruction.Kind kind) { 1.418 + this.set = set; 1.419 + this.opcode = opcode; 1.420 + this.kind = kind; 1.421 + } 1.422 + 1.423 + public final Set set; 1.424 + public final int opcode; 1.425 + public final Instruction.Kind kind; 1.426 + 1.427 + /** Get the Opcode for a simple standard 1-byte opcode. */ 1.428 + public static Opcode get(int opcode) { 1.429 + return stdOpcodes[opcode]; 1.430 + } 1.431 + 1.432 + /** Get the Opcode for 1- or 2-byte opcode. */ 1.433 + public static Opcode get(int opcodePrefix, int opcode) { 1.434 + Opcode[] block = getOpcodeBlock(opcodePrefix); 1.435 + return (block == null ? null : block[opcode]); 1.436 + } 1.437 + 1.438 + private static Opcode[] getOpcodeBlock(int opcodePrefix) { 1.439 + switch (opcodePrefix) { 1.440 + case 0: 1.441 + return stdOpcodes; 1.442 + case WIDE: 1.443 + return wideOpcodes; 1.444 + case NONPRIV: 1.445 + return nonPrivOpcodes; 1.446 + case PRIV: 1.447 + return privOpcodes; 1.448 + default: 1.449 + return null; 1.450 + } 1.451 + 1.452 + } 1.453 + 1.454 + private static Opcode[] stdOpcodes = new Opcode[256]; 1.455 + private static Opcode[] wideOpcodes = new Opcode[256]; 1.456 + private static Opcode[] nonPrivOpcodes = new Opcode[256]; 1.457 + private static Opcode[] privOpcodes = new Opcode[256]; 1.458 + static { 1.459 + for (Opcode o: values()) 1.460 + getOpcodeBlock(o.opcode >> 8)[o.opcode & 0xff] = o; 1.461 + } 1.462 + 1.463 + /** The byte prefix for the wide instructions. */ 1.464 + public static final int WIDE = 0xc4; 1.465 + /** The byte prefix for the PicoJava nonpriv instructions. */ 1.466 + public static final int NONPRIV = 0xfe; 1.467 + /** The byte prefix for the PicoJava priv instructions. */ 1.468 + public static final int PRIV = 0xff; 1.469 + 1.470 + public enum Set { 1.471 + /** Standard opcodes. */ 1.472 + STANDARD, 1.473 + /** Legacy support for PicoJava opcodes. */ 1.474 + PICOJAVA }; 1.475 +}