pub trait InstructionStream {
// Required methods
fn create_label(&mut self) -> LabelRef;
fn create_label_attached(&mut self) -> LabelRef;
fn attach_label(&mut self, label: LabelRef);
fn write_byte(&mut self, byte: u8);
fn write_word(&mut self, word: u16);
fn write_double_word(&mut self, word: u32);
fn write_quad_word(&mut self, word: u64);
fn write_double_quad_word(&mut self, word: u128);
fn finish(self) -> Product;
}
Expand description
A target-specific stream of instructions.
An instruction stream inputs instructions and immediately encodes them into machine code for its respective target architecture. Relocation is performed later.
Required Methods§
Sourcefn create_label(&mut self) -> LabelRef
fn create_label(&mut self) -> LabelRef
Creates a new label.
The label will be created without being attached to any index. If the label is used before it is attached, it will be used as a relocation rather than pre-calculating the offset.
Sourcefn create_label_attached(&mut self) -> LabelRef
fn create_label_attached(&mut self) -> LabelRef
Creates a new label and attaches it to the current index.
When the label is used, AsmKit will automatically calculate the offset of the label instead of creating a relocation.
Sourcefn attach_label(&mut self, label: LabelRef)
fn attach_label(&mut self, label: LabelRef)
Attaches a label to the current index.
After attaching, AsmKit will automatically calculate the offset of the label instead of creating an unnecessary relocation for it.
This will overwrite any previous label at the provided reference.
Sourcefn write_byte(&mut self, byte: u8)
fn write_byte(&mut self, byte: u8)
Writes a raw byte into the instruction stream at the current index.
Sourcefn write_word(&mut self, word: u16)
fn write_word(&mut self, word: u16)
Writes a raw word into the instruction stream at the current index.
The value will be swapped into the endianness of the target, by the implementor of InstructionStream
.
Sourcefn write_double_word(&mut self, word: u32)
fn write_double_word(&mut self, word: u32)
Writes a raw double word into the instruction stream at the current index.
The value will be swapped into the endianness of the target, by the implementor of InstructionStream
.
Sourcefn write_quad_word(&mut self, word: u64)
fn write_quad_word(&mut self, word: u64)
Writes a raw quadruple word into the instruction stream at the current index.
The value will be swapped into the endianness of the target, by the implementor of InstructionStream
.
Sourcefn write_double_quad_word(&mut self, word: u128)
fn write_double_quad_word(&mut self, word: u128)
Writes a raw double quadruple word into the instruction stream at the current index.
The value will be swapped into the endianness of the target, by the implementor of InstructionStream
.