Enum alure::instr::BytesOp [−][src]
pub enum BytesOp {}Show variants
Put(u8, ByteStr), Mov(u8, u8), Swp(u8, u8), Fill(u8, Reg32, Reg32, Reg32, bool), Len(u8, RegA, Reg32), Cnt(u8, Reg16, Reg16), Eq(u8, u8), Con(u8, u8, u6, Reg32, Reg32), Find(u8, u8), Extr(Reg32, RegR, Reg16, Reg16), Inj(Reg32, RegR, Reg16, Reg16), Join(u8, u8, u8), Splt(SplitFlag, Reg32, u8, u8, u8), Ins(InsertFlag, Reg32, u8, u8), Del(DeleteFlag, RegA2, Reg32, RegA2, Reg32, bool, bool, u8, u8), Rev(u8, u8),
Expand description
Operations on byte strings.
All of these operations either set st0
to false
, if an exception occurred during their
execution, or do not modify st0
register value. Since each of the exceptions can be predicted
with a code run by VM beforehand (unlike for arithmetic exceptions), the absence of st0
value
change upon success allows batching multiple string operations and checking their final result,
while still maintaining ability to predict/detect which of the operations has failed.
Variants
Put bytestring into a byte string register
Move bytestring value between registers
Swap bytestring value between registers
Fill segment of bytestring with specific byte value, setting the length of the string in the destination register to specific value.
The start offset is the least offset from one of the a16
register provided in offset
arguments, the end offset is the greatest one. If any of the offsets exceeds the length of
the string in the destination register, operation behaviour is defined by the provided
boolean flag:
- if the flag is
true
, the string length is extended to the largest of the offsets and all bytes between previous string length and start offset are filled with zeros, settingst0
value tofalse
; - if the flag is
false
, the destination register is set toNone
andst0
is set tofalse
. If both of the offsets lie within the length of the string, thest0
register value is not modified.
Put length of the string into the destination register. If a8
register is specified and
the value does not fit into it, the destination is set to None
and st0
to false
.
Otherwise st0
value is not changed.
Count number of byte occurrences from the a8
register with the provided index within the
string and stores that value into a16
register with the provided index.
Check equality of two strings, putting result into st0
Compute offset and length of the n
th fragment shared between two strings (“conjoint
fragment”), putting it to the destination u16
registers. If strings have no conjoint
fragment sets destination to None
.
Count number of occurrences of one string within another putting result to a16[0]
Extract byte string slice into general r
register. The length of the extracted string is
equal to the bit dimension of the destination register. If the bit size of the destination
plus the initial offset exceeds string length the rest of the destination register bits is
filled with zeros and st0
is set to false
. Otherwise, st0
value is not modified.
Inject general R
register value at a given position to string register, replacing value
of the corresponding bytes. If the insert offset is larger than the current length of the
string, the length is extended and all bytes inbetween previous length and the new length
are initialized with zeros. If the length of the inserted string plus insert offset exceeds
the maximum string register length (2^16 bytes), than the destination register is set to
None
state and st0
is set to false
. Otherwise, st0
value is not modified.
Join bytestrings from two registers into destination, overwriting its value. If the length
of the joined string exceeds the maximum string register length (2^16 bytes), than the
destination register is set to None
state and st0
is set to false
. Otherwise,
st0
value is not modified.
Split bytestring at a given offset taken from a16
register into two destination strings,
overwriting their value. If offset exceeds the length of the string in the register,
than the behaviour is determined by the SplitFlag
value.
+-------------------- | | .... +-------------------- ^ ^ | +-- Split offset (`offset`) +-- Source string length (`src_len`)
offset == 0
:
(1) first, second <- None; st0
<- false
(2) first <- None, second <- src_len > 0
? src : None; st0
<- false
(3) first <- None, second <- src_len > 0
? src : zero-len; st0
<- false
(4) first <- zero-len, second <- src_len > 0
? src : zero-len
offset > 0 && offset < src_len
: st0
always set to false
(1) first, second <- None
(5) first <- short, second <- None
(6) first <- short, second <- zero-len
(7) first <- zero-ext, second <- None
(8) first <- zero-ext, second <- zero-len
offset = src_len
:
(1) first, second <- None; st0
<- false
(5,7) first <- ok, second <- None; st0
<- false
(6,8) first <- ok, second <- zero-len
offset > src_len
: operation succeeds anyway, st0
value is not changed
Rule on st0
changes: if at least one of the destination registers is set to None
, or
offset
value exceeds source string length, st0
is set to false
; otherwise its value
is not modified
Ins(InsertFlag, Reg32, u8, u8)
Insert value from one of bytestring register at a given index of other bytestring register,
shifting string bytes. If the destination register does not fit the length of the new
string, or the offset exceeds the length of destination string operation behaviour is
defined by the provided InsertFlag
.
+-------------------- | | .... +-------------------- ^ ^ | +-- Insert offset (`offset`) +-- Destination string length (`dst_len`)
offset < dst_len && src_len + dst_len > 2^16
:
(6) Set destination to None
(7) Cut destination string part exceeding 2^16
(8) Reduce src_len
such that it will fit the destination
offset > dst_len && src_len + dst_len + offset <= 2^16
:
(1) Set destination to None
(2) Fill destination from dst_let
to offset
with zeros
(3) Use src_len
instead of offset
offset > dst_len && src_len + dst_len + offset > 2^16
:
(4) Set destination to None
(5) Fill destination from dst_let
to offset
with zeros and cut source string part
exceeding 2^16
(6-8) Use src_len
instead of offset
and use flag value from the first section
In all of these cases st0
is set to false
. Otherwise, st0
value is not modified.
Delete bytes in a given range, shifting the remaining bytes leftward. The start offset is
the least offset from one of the a16
register provided in offset
arguments, the end
offset is the greatest one. If any of the offsets exceeds the length of the string in
the destination register, operation behaviour is defined by the provided [DelFlag
]
argument.
+---------------------------------- | | .... +---------------------------------- ^ ^ ^ | | +-- End offset (`offset_end`) | +-- Source string length (`src_len`) +-- Start offset (`offset_start`)
offset_start > src_len
:
(1) set destination to None
(2) set destination to zero-length string
offset_end > src_len && offser_start <= src_len
:
(1) set destination to None
(3) set destination to the fragment of the string offset_start..src_len
(4) set destination to the fragment of the string offset_start..src_len
and extend
its length up to offset_end - offset_start
with trailing zeros.
flag1
and flag2
arguments indicate whether st0
should be set to false
if
offset_start > src_len
and offset_end > src_len && offser_start <= src_len
.
In all other cases, st0
value is not modified.
Revert byte order of the string
Trait Implementations
Returns number of bytes which instruction and its argument occupies
Returns range of instruction btecodes covered by a set of operations
Returns byte representing instruction code (without its arguments)
fn write_args<W>(&self, writer: &mut W) -> Result<(), EncodeError> where
W: Write,
EncodeError: From<<W as Write>::Error>,
[src]
fn write_args<W>(&self, writer: &mut W) -> Result<(), EncodeError> where
W: Write,
EncodeError: From<<W as Write>::Error>,
[src]Writes instruction arguments as bytecode, omitting instruction code byte
fn read<R>(reader: &mut R) -> Result<Self, DecodeError> where
R: Read,
DecodeError: From<<R as Read>::Error>,
[src]
fn read<R>(reader: &mut R) -> Result<Self, DecodeError> where
R: Read,
DecodeError: From<<R as Read>::Error>,
[src]Reads the instruction from bytecode
fn write<W>(&self, writer: &mut W) -> Result<(), EncodeError> where
W: Write,
EncodeError: From<<W as Write>::Error>,
[src]
fn write<W>(&self, writer: &mut W) -> Result<(), EncodeError> where
W: Write,
EncodeError: From<<W as Write>::Error>,
[src]Writes the instruction as bytecode
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for BytesOp
impl UnwindSafe for BytesOp
Blanket Implementations
Mutably borrows from an owned value. Read more