| 1 |
// |
| 2 |
// Copyright (C) 2010 Wayne Meissner |
| 3 |
// Copyright (c) 2008-2009, Petr Kobalicek <[email protected]> |
| 4 |
// |
| 5 |
// Permission is hereby granted, free of charge, to any person |
| 6 |
// obtaining a copy of this software and associated documentation |
| 7 |
// files (the "Software"), to deal in the Software without |
| 8 |
// restriction, including without limitation the rights to use, |
| 9 |
// copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 |
// copies of the Software, and to permit persons to whom the |
| 11 |
// Software is furnished to do so, subject to the following |
| 12 |
// conditions: |
| 13 |
// |
| 14 |
// The above copyright notice and this permission notice shall be |
| 15 |
// included in all copies or substantial portions of the Software. |
| 16 |
// |
| 17 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 19 |
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 |
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 21 |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 22 |
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 23 |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 24 |
// OTHER DEALINGS IN THE SOFTWARE. |
| 25 |
|
| 26 |
package com.kenai.jnr.x86asm; |
| 27 |
|
| 28 |
import static com.kenai.jnr.x86asm.REG.*; |
| 29 |
import static com.kenai.jnr.x86asm.SEGMENT.*; |
| 30 |
|
| 31 |
/** |
| 32 |
* |
| 33 |
*/ |
| 34 |
@Deprecated |
| 35 |
public final class Mem extends Operand { |
| 36 |
//! @brief Base register index, see @c REG. |
| 37 |
private final int base; |
| 38 |
//! @brief Index register index, see @c REG. |
| 39 |
private final int index; |
| 40 |
//! @brief Index register shift (0 to 3 included). |
| 41 |
private final int shift; |
| 42 |
//! @brief Segment override prefix, see @c AsmJit::SEGMENT. |
| 43 |
private final SEGMENT segmentPrefix; |
| 44 |
|
| 45 |
private final Label label; |
| 46 |
private final long target; |
| 47 |
|
| 48 |
private final long displacement; |
| 49 |
|
| 50 |
|
| 51 |
Mem(Label label, long displacement, int size) { |
| 52 |
this(NO_REG, NO_REG, 0, SEGMENT_NONE, label, 0, displacement, size); |
| 53 |
} |
| 54 |
|
| 55 |
Mem(Register base, long displacement, int size) { |
| 56 |
this(base.index(), NO_REG, 0, SEGMENT_NONE, null, 0, displacement, size); |
| 57 |
} |
| 58 |
|
| 59 |
Mem(Register base, Register index, int shift, long displacement, int size) { |
| 60 |
this(base.index(), index.index(), shift, SEGMENT_NONE, null, 0, displacement, size); |
| 61 |
} |
| 62 |
|
| 63 |
Mem(Label label, Register index, int shift, long disp, int ptrSize) { |
| 64 |
this(0, index.index(), shift, SEGMENT_NONE, label, 0, disp, ptrSize); |
| 65 |
} |
| 66 |
|
| 67 |
Mem(long target, long disp, SEGMENT segmentPrefix, int ptrSize) { |
| 68 |
this(NO_REG, NO_REG, 0, segmentPrefix, null, target, disp, ptrSize); |
| 69 |
} |
| 70 |
|
| 71 |
Mem(long target, Register index, int shift, SEGMENT segmentPrefix, long disp, int ptrSize) { |
| 72 |
this(NO_REG, index.index(), shift, segmentPrefix, null, target, disp, ptrSize); |
| 73 |
} |
| 74 |
|
| 75 |
private Mem(int base, int index, int shift, SEGMENT segmentPrefix, Label label, long target, long displacement, int size) { |
| 76 |
super(OP.OP_MEM, size); |
| 77 |
|
| 78 |
assert(shift <= 3); |
| 79 |
|
| 80 |
this.base = base; |
| 81 |
this.index = index; |
| 82 |
this.shift = shift; |
| 83 |
this.segmentPrefix = segmentPrefix; |
| 84 |
this.label = label; |
| 85 |
this.target = target; |
| 86 |
this.displacement = displacement; |
| 87 |
} |
| 88 |
|
| 89 |
public final boolean hasLabel() { |
| 90 |
return label != null; |
| 91 |
} |
| 92 |
|
| 93 |
//! @brief Return if address has base register. |
| 94 |
public final boolean hasBase() { |
| 95 |
return base != NO_REG; |
| 96 |
} |
| 97 |
|
| 98 |
//! @brief Return if address has index register. |
| 99 |
boolean hasIndex() { |
| 100 |
return index != NO_REG; |
| 101 |
} |
| 102 |
|
| 103 |
public final SEGMENT segmentPrefix() { |
| 104 |
return segmentPrefix; |
| 105 |
} |
| 106 |
|
| 107 |
public final int base() { |
| 108 |
return base; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
public final long displacement() { |
| 113 |
return displacement; |
| 114 |
} |
| 115 |
|
| 116 |
public final int index() { |
| 117 |
return index; |
| 118 |
} |
| 119 |
|
| 120 |
public final Label label() { |
| 121 |
return label; |
| 122 |
} |
| 123 |
|
| 124 |
public final int shift() { |
| 125 |
return shift; |
| 126 |
} |
| 127 |
|
| 128 |
public final long target() { |
| 129 |
return target; |
| 130 |
} |
| 131 |
|
| 132 |
} |