hotspot/agent/src/share/classes/sun/jvm/hotspot/asm/x86/X86Instruction.java
changeset 13911 e59cfb5f223b
parent 13910 aded5e617602
parent 13909 9b94bf4dcc0c
child 13912 3bd874584fc0
equal deleted inserted replaced
13910:aded5e617602 13911:e59cfb5f223b
     1 /*
       
     2  * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.
       
     8  *
       
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    12  * version 2 for more details (a copy is included in the LICENSE file that
       
    13  * accompanied this code).
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License version
       
    16  * 2 along with this work; if not, write to the Free Software Foundation,
       
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    18  *
       
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    20  * or visit www.oracle.com if you need additional information or have any
       
    21  * questions.
       
    22  *
       
    23  */
       
    24 
       
    25 package sun.jvm.hotspot.asm.x86;
       
    26 
       
    27 import sun.jvm.hotspot.asm.*;
       
    28 
       
    29 public abstract class X86Instruction implements Instruction, X86Opcodes {
       
    30    final private String name;
       
    31    final private int size;
       
    32    final private int prefixes;
       
    33 
       
    34    public X86Instruction(String name, int size, int prefixes) {
       
    35       this.name = name;
       
    36       this.size = size;
       
    37       this.prefixes = prefixes;
       
    38    }
       
    39 
       
    40    public abstract String asString(long currentPc, SymbolFinder symFinder);
       
    41 
       
    42    public String getName() {
       
    43       return name;
       
    44    }
       
    45 
       
    46    public String getPrefixString() {
       
    47       StringBuffer buf = new StringBuffer();
       
    48       if ((prefixes & PREFIX_REPZ) != 0)
       
    49          buf.append("repz ");
       
    50       if ((prefixes & PREFIX_REPNZ) != 0)
       
    51          buf.append("repnz ");
       
    52       if ((prefixes & PREFIX_LOCK) != 0)
       
    53          buf.append("lock ");
       
    54 
       
    55       return buf.toString();
       
    56    }
       
    57 
       
    58    protected String getOperandAsString(Operand op) {
       
    59       StringBuffer buf = new StringBuffer();
       
    60       if ((op instanceof Register) || (op instanceof Address)) {
       
    61          buf.append(op.toString());
       
    62       } else {
       
    63          Number number = ((Immediate)op).getNumber();
       
    64          buf.append("0x");
       
    65          buf.append(Integer.toHexString(number.intValue()));
       
    66       }
       
    67       return buf.toString();
       
    68    }
       
    69 
       
    70    public int getSize() {
       
    71       return size;
       
    72    }
       
    73 
       
    74    public boolean isArithmetic() {
       
    75       return false;
       
    76    }
       
    77 
       
    78    public boolean isBranch() {
       
    79       return false;
       
    80    }
       
    81 
       
    82    public boolean isCall() {
       
    83       return false;
       
    84    }
       
    85 
       
    86    public boolean isFloat() {
       
    87       return false;
       
    88    }
       
    89 
       
    90    public boolean isIllegal() {
       
    91       return false;
       
    92    }
       
    93 
       
    94    public boolean isLoad() {
       
    95       return false;
       
    96    }
       
    97 
       
    98    public boolean isLogical() {
       
    99       return false;
       
   100    }
       
   101 
       
   102    public boolean isMove() {
       
   103       return false;
       
   104    }
       
   105 
       
   106    public boolean isReturn() {
       
   107       return false;
       
   108    }
       
   109 
       
   110    public boolean isShift() {
       
   111       return false;
       
   112    }
       
   113 
       
   114    public boolean isStore() {
       
   115       return false;
       
   116    }
       
   117 
       
   118    public boolean isTrap() {
       
   119       return false;
       
   120    }
       
   121 
       
   122    public boolean isNoop() {
       
   123       return false;
       
   124    }
       
   125 
       
   126    protected static String comma = ", ";
       
   127    protected static String spaces = "\t";
       
   128 }