1 /* |
|
2 * Copyright (c) 2002, 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.sparc; |
|
26 |
|
27 import sun.jvm.hotspot.asm.*; |
|
28 |
|
29 public abstract class SPARCFormat3AInstruction extends SPARCInstruction { |
|
30 final protected int opcode; |
|
31 final protected SPARCRegister rs1; |
|
32 final protected ImmediateOrRegister operand2; |
|
33 final protected SPARCRegister rd; |
|
34 |
|
35 public SPARCFormat3AInstruction(String name, int opcode, SPARCRegister rs1, |
|
36 ImmediateOrRegister operand2, SPARCRegister rd) { |
|
37 super(name); |
|
38 this.opcode = opcode; |
|
39 this.rs1 = rs1; |
|
40 this.operand2 = operand2; |
|
41 this.rd = rd; |
|
42 } |
|
43 |
|
44 protected String getOperand2String() { |
|
45 StringBuffer buf = new StringBuffer(); |
|
46 if (operand2.isRegister()) { |
|
47 buf.append(operand2.toString()); |
|
48 } else { |
|
49 Number number = ((Immediate)operand2).getNumber(); |
|
50 buf.append("0x"); |
|
51 buf.append(Integer.toHexString(number.intValue())); |
|
52 } |
|
53 return buf.toString(); |
|
54 } |
|
55 |
|
56 protected String getDescription() { |
|
57 StringBuffer buf = new StringBuffer(); |
|
58 buf.append(getName()); |
|
59 buf.append(spaces); |
|
60 buf.append(rs1.toString()); |
|
61 buf.append(comma); |
|
62 buf.append(getOperand2String()); |
|
63 buf.append(comma); |
|
64 buf.append(rd.toString()); |
|
65 return buf.toString(); |
|
66 } |
|
67 |
|
68 public String asString(long currentPc, SymbolFinder symFinder) { |
|
69 return getDescription(); |
|
70 } |
|
71 |
|
72 public int getOpcode() { |
|
73 return opcode; |
|
74 } |
|
75 |
|
76 public SPARCRegister getDestinationRegister() { |
|
77 return rd; |
|
78 } |
|
79 |
|
80 public ImmediateOrRegister getOperand2() { |
|
81 return operand2; |
|
82 } |
|
83 |
|
84 public SPARCRegister getSourceRegister1() { |
|
85 return rs1; |
|
86 } |
|
87 } |
|