pub enum Expression {
Show 34 variants
Constant(u32),
SymbolAddressIndex(u16),
SectionAddressIndex(u16),
Bank(u16),
SectionOffset(u16),
Offset(u16),
SectionStart(u16),
GroupStart(u16),
GroupOffset(u16),
Segment(u16),
GroupOrg(u16),
SectionEnd(u16),
Equals(Box<Expression>, Box<Expression>),
NotEquals(Box<Expression>, Box<Expression>),
LTE(Box<Expression>, Box<Expression>),
LessThan(Box<Expression>, Box<Expression>),
GTE(Box<Expression>, Box<Expression>),
GreaterThan(Box<Expression>, Box<Expression>),
Add(Box<Expression>, Box<Expression>),
Subtract(Box<Expression>, Box<Expression>),
Multiply(Box<Expression>, Box<Expression>),
Divide(Box<Expression>, Box<Expression>),
And(Box<Expression>, Box<Expression>),
Or(Box<Expression>, Box<Expression>),
XOR(Box<Expression>, Box<Expression>),
LeftShift(Box<Expression>, Box<Expression>),
RightShift(Box<Expression>, Box<Expression>),
Mod(Box<Expression>, Box<Expression>),
Dashes(Box<Expression>, Box<Expression>),
Revword(Box<Expression>, Box<Expression>),
Check0(Box<Expression>, Box<Expression>),
Check1(Box<Expression>, Box<Expression>),
BitRange(Box<Expression>, Box<Expression>),
ArshiftChk(Box<Expression>, Box<Expression>),
}Expand description
An expression used in relocations.
PSY-Q uses a sophisticated expression system for calculating relocated addresses. Expressions can be constants, symbol references, or complex arithmetic operations.
Each component of an expression has a unique on disk format. There are no synchronization points, or sizes encoded into the structure, so it is important that each type is explicitly modeled.
Linker expressions are similar, but not identical to assembler expressions and some built-in functions are available in both.
§Example Expressions
$1000- Constant value 0x1000[5]- Address of symbol #5sectbase(2)- Base address of section #2(sectstart(1)+$100)- Section 1 start plus 0x100
Variants§
Constant(u32)
SymbolAddressIndex(u16)
SectionAddressIndex(u16)
Bank(u16)
SectionOffset(u16)
Offset(u16)
SectionStart(u16)
Start address of a section.
sectstart(x)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0xC |
| 1 | u16 | Section ID. |
GroupStart(u16)
GroupOffset(u16)
The offset of a group.
Untested
groupof(x)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x10 |
| 1 | u16 | Group ID. |
Segment(u16)
GroupOrg(u16)
The ORG address of a group for a symbol.
grouporg(x)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x14 |
| 1 | u16 | Symbol ID. |
SectionEnd(u16)
End address of a section.
sectend(X)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x16 |
| 1 | u16 | Section ID. |
Equals(Box<Expression>, Box<Expression>)
Equality comparison.
(a=b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x20 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
NotEquals(Box<Expression>, Box<Expression>)
Inequality comparison.
(a<>b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x22 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
LTE(Box<Expression>, Box<Expression>)
Less than or equal.
(a<=b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x24 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
LessThan(Box<Expression>, Box<Expression>)
Less than.
(a<b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x26 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
GTE(Box<Expression>, Box<Expression>)
Greater than or equal.
(a>=b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x28 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
GreaterThan(Box<Expression>, Box<Expression>)
Greater than.
(a>b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x2A |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Add(Box<Expression>, Box<Expression>)
Addition.
(a+b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x2C |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Subtract(Box<Expression>, Box<Expression>)
Subtraction.
(a-b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x2E |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Multiply(Box<Expression>, Box<Expression>)
Multiplication.
(a*b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x30 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Divide(Box<Expression>, Box<Expression>)
Division.
(a/b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x32 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
And(Box<Expression>, Box<Expression>)
Bitwise AND.
(a&b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x34 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Or(Box<Expression>, Box<Expression>)
Bitwise OR operator.
(a!b)Instead of using the typical | (pipe) symbol, the default rendering
of this operator is the ! (exclamation point/bang) symbol. In the
assembler, the | symbol acts as an alias for !.
§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x36 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
XOR(Box<Expression>, Box<Expression>)
Bitwise XOR.
(a^b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x38 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
LeftShift(Box<Expression>, Box<Expression>)
Left shift.
(a<<b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x3A |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
RightShift(Box<Expression>, Box<Expression>)
Right shift.
(a>>b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x3C |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Mod(Box<Expression>, Box<Expression>)
Modulo.
(a%b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x3E |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Dashes(Box<Expression>, Box<Expression>)
Dashes operator.
(a---b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x40 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Revword(Box<Expression>, Box<Expression>)
Reverse word.
(a-revword-b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x42 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Check0(Box<Expression>, Box<Expression>)
Check0.
(a-check0-b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x44 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Check1(Box<Expression>, Box<Expression>)
Check1.
(a-check1-b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x46 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
BitRange(Box<Expression>, Box<Expression>)
Bit range extraction.
(a-bitrange-b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x48 |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
ArshiftChk(Box<Expression>, Box<Expression>)
Arithmetic shift with check.
(a-arshift_chk-b)§Structure on Disk
| Offset | Type | Description |
|---|---|---|
| 0 | u8 | Magic: 0x4A |
| 1 | Expression | Left Expression. |
| sizeof(left_expression) + 1 | Expression | Right Expression. |
Trait Implementations§
Source§impl BinRead for Expression
impl BinRead for Expression
Source§fn read_options<R: Read + Seek>(
__binrw_generated_var_reader: &mut R,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<Self>
fn read_options<R: Read + Seek>( __binrw_generated_var_reader: &mut R, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<Self>
Source§fn read<R>(reader: &mut R) -> Result<Self, Error>
fn read<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments. Read moreSource§fn read_be<R>(reader: &mut R) -> Result<Self, Error>
fn read_be<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
big-endian byte order. Read moreSource§fn read_le<R>(reader: &mut R) -> Result<Self, Error>
fn read_le<R>(reader: &mut R) -> Result<Self, Error>
Self from the reader using default arguments and assuming
little-endian byte order. Read moreSource§fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
fn read_ne<R>(reader: &mut R) -> Result<Self, Error>
T from the reader assuming native-endian byte order. Read moreSource§fn read_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self from the reader using the given arguments. Read moreSource§fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
fn read_be_args<R>(reader: &mut R, args: Self::Args<'_>) -> Result<Self, Error>
Self from the reader, assuming big-endian byte order, using the
given arguments. Read moreSource§impl BinWrite for Expression
impl BinWrite for Expression
Source§fn write_options<W: Write + Seek>(
&self,
__binrw_generated_var_writer: &mut W,
__binrw_generated_var_endian: Endian,
__binrw_generated_var_arguments: Self::Args<'_>,
) -> BinResult<()>
fn write_options<W: Write + Seek>( &self, __binrw_generated_var_writer: &mut W, __binrw_generated_var_endian: Endian, __binrw_generated_var_arguments: Self::Args<'_>, ) -> BinResult<()>
Source§fn write<W>(&self, writer: &mut W) -> Result<(), Error>
fn write<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer using default arguments. Read moreSource§fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_be<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming big-endian byte order. Read moreSource§fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_le<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming little-endian byte order. Read moreSource§fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
fn write_ne<W>(&self, writer: &mut W) -> Result<(), Error>
Self to the writer assuming native-endian byte order. Read moreSource§fn write_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self to the writer using the given arguments. Read moreSource§fn write_be_args<W>(
&self,
writer: &mut W,
args: Self::Args<'_>,
) -> Result<(), Error>
fn write_be_args<W>( &self, writer: &mut W, args: Self::Args<'_>, ) -> Result<(), Error>
Self to the writer, assuming big-endian byte order, using the
given arguments. Read moreSource§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl Display for Expression
impl Display for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl ReadEndian for Expression
impl ReadEndian for Expression
Source§const ENDIAN: EndianKind
const ENDIAN: EndianKind
Source§impl WriteEndian for Expression
impl WriteEndian for Expression
Source§const ENDIAN: EndianKind
const ENDIAN: EndianKind
impl StructuralPartialEq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)