[][src]Enum inc::x86::Ins

pub enum Ins {
    Add {
        r: Register,
        v: Operand,
    },
    And {
        r: Register,
        v: Operand,
    },
    Call(String),
    Cmp {
        r: Register,
        with: i64,
    },
    Enter,
    Je(String),
    Jmp(String),
    Label(String),
    Leave,
    Save {
        r: Register,
        si: i64,
    },
    Load {
        r: Register,
        si: i64,
    },
    Mov {
        from: Operand,
        to: Operand,
    },
    Mul {
        v: Operand,
    },
    Pop(Register),
    Push(Register),
    Ret,
    Sar {
        r: Register,
        v: i64,
    },
    Sal {
        r: Register,
        v: i64,
    },
    Sub {
        r: Register,
        v: Operand,
    },
    Slice(String),
}

Each x86 instruction this compiler understands.

This type fundamentally limits what code can be generated and ideally no other part of the compiler should generate ASM with strings.

Variants

Add

Add v to register r

Fields of Add

r: Registerv: Operand
And

Logical and of v to register r

Fields of And

r: Registerv: Operand
Call(String)

Unconditional function call

Cmp

Compare the value to register RAX

Fields of Cmp

r: Registerwith: i64
Enter

x86 function preamble

Not really a single instruction but having this as a single operation makes it easier for callers of this module.

Je(String)

Jump to the specified label if last comparison resulted in equality

Jmp(String)

Unconditionally jump to the specified label

Label(String)

A label is a target to jump to

Leave

Exit a function and clean up. See Enter

Save

Save a register r to stack at index si

Fields of Save

r: Registersi: i64
Load

Load a value at stack index si to register r

Fields of Load

r: Registersi: i64
Mov

Mov! At least one of the operands must be a register, moving from RAM to RAM isn't a valid op.

Fields of Mov

from: Operandto: Operand
Mul

Multiply register AX with value v and move result to register RAX

Fields of Mul

v: Operand
Pop(Register)

Pop a register r from stack

Push(Register)

Push a register r to stack

Ret

Return from the calling function

Sar

Shift register r right by v bits; r = r / 2^v

Fields of Sar

r: Registerv: i64
Sal

Shift register r left by v bits; r = r * 2^v

Fields of Sal

r: Registerv: i64
Sub

Sub k from register r

Fields of Sub

r: Registerv: Operand
Slice(String)

Raw slices for compatibility

Often it can be just convenient to hand write some assembly and eventually port it to a sensible type here. Till then this Variant is a goods stop gap.

Trait Implementations

impl Clone for Ins[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl From<Ins> for ASM[src]

Convert a single operation to ASM

impl Debug for Ins[src]

impl Display for Ins[src]

Pretty print a single ASM instruction.

impl Add<Ins> for ASM[src]

Add operations to ASM with overloaded asm' = asm + op.

NOTE: This is pretty inefficient due to copying of self.

type Output = Self

The resulting type after applying the + operator.

impl Add<Ins> for Ins[src]

Concat Ins to get ASM; asm = op + op

NOTE: This is pretty inefficient due to copying both arguments.

type Output = ASM

The resulting type after applying the + operator.

impl AddAssign<Ins> for ASM[src]

Add operations with a easy to read asm += op short hand.

This is pretty efficient at the cost of owning the value.

Auto Trait Implementations

impl Send for Ins

impl Sync for Ins

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]