1 /* 2 * Copyright 2003 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 * CA 95054 USA or visit www.sun.com if you need additional information or 21 * have any questions. 22 * 23 */ 24 25 package sun.jvm.hotspot.asm.x86; 26 27 import sun.jvm.hotspot.asm.Address; 28 import sun.jvm.hotspot.asm.BaseIndexScaleDispAddress; 29 30 public class X86RegisterIndirectAddress extends BaseIndexScaleDispAddress { 31 32 final private X86SegmentRegister segReg; 33 34 public X86RegisterIndirectAddress(X86SegmentRegister segReg, X86Register base, X86Register index, long disp, int scale) { 35 super(base, index, disp, scale); 36 this.segReg = segReg; 37 } 38 39 public X86RegisterIndirectAddress(X86SegmentRegister segReg, X86Register base, X86Register index, long disp) { 40 super(base, index, disp, -1); 41 this.segReg = segReg; 42 } 43 44 public String toString() { 45 StringBuffer buf = new StringBuffer(); 46 if(segReg != null) { 47 buf.append(segReg.toString()); 48 buf.append(":"); 49 } 50 51 long disp = getDisplacement(); 52 if(disp != 0) 53 buf.append(disp); 54 55 sun.jvm.hotspot.asm.Register base = getBase(); 56 sun.jvm.hotspot.asm.Register index = getIndex(); 57 int scaleVal = getScale(); 58 scaleVal = 1 << scaleVal; 59 60 if( (base != null) || (index != null) || (scaleVal > 1) ) 61 buf.append('['); 62 63 if(base != null) { 64 buf.append(base.toString()); 65 if(index != null) { 66 buf.append("+"); 67 buf.append(index.toString()); 68 } 69 } 70 else { 71 if(index != null) { 72 buf.append(index.toString()); 73 } 74 } 75 76 if (scaleVal > 1) { 77 buf.append(" * "); 78 buf.append(Integer.toString(scaleVal)); 79 } 80 81 if( (base != null) || (index != null) || (scaleVal > 1) ) 82 buf.append(']'); 83 84 return buf.toString(); 85 } 86 }