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 class X86ArithmeticInstruction extends X86Instruction |
|
30 implements ArithmeticInstruction { |
|
31 final private int operation; //RTL operation |
|
32 final private Operand operand1; |
|
33 final private Operand operand2; |
|
34 final private Operand operand3; |
|
35 final private String description; |
|
36 |
|
37 public X86ArithmeticInstruction(String name, int operation, Operand op1, Operand op2, int size, int prefixes) { |
|
38 super(name, size, prefixes); |
|
39 this.operation = operation; |
|
40 this.operand1 = op1; |
|
41 this.operand2 = op2; |
|
42 this.operand3 = null; |
|
43 description = initDescription(); |
|
44 } |
|
45 |
|
46 public X86ArithmeticInstruction(String name, int operation, Operand op1, Operand op2, Operand op3, int size, int prefixes) { |
|
47 super(name, size, prefixes); |
|
48 this.operation = operation; |
|
49 this.operand1 = op1; |
|
50 this.operand2 = op2; |
|
51 this.operand3 = op3; |
|
52 description = initDescription(); |
|
53 } |
|
54 |
|
55 protected String initDescription() { |
|
56 StringBuffer buf = new StringBuffer(); |
|
57 buf.append(getPrefixString()); |
|
58 buf.append(getName()); |
|
59 buf.append(spaces); |
|
60 if (operand1 != null) { |
|
61 buf.append(getOperandAsString(operand1)); |
|
62 } |
|
63 if (operand2 != null) { |
|
64 buf.append(comma); |
|
65 buf.append(getOperandAsString(operand2)); |
|
66 } |
|
67 if(operand3 != null) { |
|
68 buf.append(comma); |
|
69 buf.append(getOperandAsString(operand3)); |
|
70 } |
|
71 return buf.toString(); |
|
72 } |
|
73 |
|
74 public String asString(long currentPc, SymbolFinder symFinder) { |
|
75 return description; |
|
76 } |
|
77 |
|
78 public Operand getArithmeticDestination() { |
|
79 return operand1; |
|
80 } |
|
81 |
|
82 public Operand getOperand1() { |
|
83 return operand1; |
|
84 } |
|
85 |
|
86 public Operand getOperand2() { |
|
87 return operand2; |
|
88 } |
|
89 |
|
90 public Operand getOperand3() { |
|
91 return operand3; |
|
92 } |
|
93 |
|
94 public Operand[] getArithmeticSources() { |
|
95 return (new Operand[] { operand1, operand2, operand3 }); |
|
96 } |
|
97 |
|
98 public int getOperation() { |
|
99 return operation; |
|
100 } |
|
101 |
|
102 public boolean isArithmetic() { |
|
103 return true; |
|
104 } |
|
105 } |
|