[][src]Enum ggbasm::ast::Instruction

pub enum Instruction {
    EmptyLine,
    AdvanceAddress(u16),
    Equ(StringExpr),
    Label(String),
    Db(Vec<u8>),
    DbExpr8(Expr),
    DbExpr16(Expr),
    Nop,
    Stop,
    Halt,
    Di,
    Ei,
    Rrca,
    Rra,
    Cpl,
    Ccf,
    Rlca,
    Rla,
    Daa,
    Scf,
    Ret(Flag),
    Reti,
    Call(FlagExpr),
    JpI16(FlagExpr),
    JpRhl,
    Jr(FlagExpr),
    IncR16(Reg16),
    IncR8(Reg8),
    IncMRhl,
    DecR16(Reg16),
    DecR8(Reg8),
    DecMRhl,
    AddR8(Reg8),
    AddMRhl,
    AddI8(Expr),
    AddRhlR16(Reg16),
    AddRspI8(Expr),
    SubR8(Reg8),
    SubMRhl,
    SubI8(Expr),
    AndR8(Reg8),
    AndMRhl,
    AndI8(Expr),
    OrR8(Reg8),
    OrMRhl,
    OrI8(Expr),
    AdcR8(Reg8),
    AdcMRhl,
    AdcI8(Expr),
    SbcR8(Reg8),
    SbcMRhl,
    SbcI8(Expr),
    XorR8(Reg8),
    XorMRhl,
    XorI8(Expr),
    CpR8(Reg8),
    CpMRhl,
    CpI8(Expr),
    LdR16I16(Reg16Expr),
    LdMI16Rsp(Expr),
    LdMRbcRa,
    LdMRdeRa,
    LdRaMRbc,
    LdRaMRde,
    LdR8R8(Reg8Reg8),
    LdR8I8(Reg8Expr),
    LdR8MRhl(Reg8),
    LdMRhlR8(Reg8),
    LdMRhlI8(Expr),
    LdMI16Ra(Expr),
    LdRaMI16(Expr),
    LdhRaMI8(Expr),
    LdhMI8Ra(Expr),
    LdhRaMRc,
    LdhMRcRa,
    LdiMRhlRa,
    LddMRhlRa,
    LdiRaMRhl,
    LddRaMRhl,
    LdRhlRspI8(Expr),
    LdRspRhl,
    Push(Reg16Push),
    Pop(Reg16Push),
    RlcR8(Reg8),
    RlcMRhl,
    RrcR8(Reg8),
    RrcMRhl,
    RlR8(Reg8),
    RlMRhl,
    RrR8(Reg8),
    RrMRhl,
    SlaR8(Reg8),
    SlaMRhl,
    SraR8(Reg8),
    SraMRhl,
    SwapR8(Reg8),
    SwapMRhl,
    SrlR8(Reg8),
    SrlMRhl,
    BitBitR8(ExprReg8),
    BitBitMRhl(Expr),
    ResBitR8(ExprReg8),
    ResBitMRhl(Expr),
    SetBitR8(ExprReg8),
    SetBitMRhl(Expr),
}

The main type in the AST, the parser creates an Instruction for each line in a *.asm

Key:

  • R16 - 16 bit register
  • R8 - 8 bit register
  • Rhl - the hl register
  • Ra - the a register
  • MR16 - 8 bit value in memory pointed at by a 16 bit register
  • MRhl - 8 bit value in memory pointed at by the HL register
  • MRc - 8 bit value in memory pointed at by 0xFF + the register C
  • I8 - immediate 8 bit value
  • I16 - immediate 16 bit value
  • Bit - an index to a bit

Variants

EmptyLine

Keeping track of empty lines makes it easier to refer errors back to a line number

AdvanceAddress(u16)

the address within the current ROM bank

Equ(StringExpr)
Label(String)
Db(Vec<u8>)
DbExpr8(Expr)
DbExpr16(Expr)
Nop
Stop
Halt
Di
Ei
Rrca
Rra
Cpl
Ccf
Rlca
Rla
Daa
Scf
Ret(Flag)
Reti
Call(FlagExpr)
JpI16(FlagExpr)
JpRhl
Jr(FlagExpr)
IncR16(Reg16)
IncR8(Reg8)
IncMRhl
DecR16(Reg16)
DecR8(Reg8)
DecMRhl
AddR8(Reg8)
AddMRhl
AddI8(Expr)
AddRhlR16(Reg16)
AddRspI8(Expr)
SubR8(Reg8)
SubMRhl
SubI8(Expr)
AndR8(Reg8)
AndMRhl
AndI8(Expr)
OrR8(Reg8)
OrMRhl
OrI8(Expr)
AdcR8(Reg8)
AdcMRhl
AdcI8(Expr)
SbcR8(Reg8)
SbcMRhl
SbcI8(Expr)
XorR8(Reg8)
XorMRhl
XorI8(Expr)
CpR8(Reg8)
CpMRhl
CpI8(Expr)
LdR16I16(Reg16Expr)
LdMI16Rsp(Expr)
LdMRbcRa
LdMRdeRa
LdRaMRbc
LdRaMRde
LdR8R8(Reg8Reg8)
LdR8I8(Reg8Expr)
LdR8MRhl(Reg8)
LdMRhlR8(Reg8)
LdMRhlI8(Expr)
LdMI16Ra(Expr)
LdRaMI16(Expr)
LdhRaMI8(Expr)
LdhMI8Ra(Expr)
LdhRaMRc
LdhMRcRa
LdiMRhlRa
LddMRhlRa
LdiRaMRhl
LddRaMRhl
LdRhlRspI8(Expr)
LdRspRhl
Push(Reg16Push)
RlcR8(Reg8)
RlcMRhl
RrcR8(Reg8)
RrcMRhl
RlR8(Reg8)
RlMRhl
RrR8(Reg8)
RrMRhl
SlaR8(Reg8)
SlaMRhl
SraR8(Reg8)
SraMRhl
SwapR8(Reg8)
SwapMRhl
SrlR8(Reg8)
SrlMRhl
BitBitR8(ExprReg8)
BitBitMRhl(Expr)
ResBitR8(ExprReg8)
ResBitMRhl(Expr)
SetBitR8(ExprReg8)
SetBitMRhl(Expr)

Implementations

impl Instruction[src]

pub fn write_to_rom(
    &self,
    rom: &mut Vec<u8>,
    constants: &HashMap<String, i64>
) -> Result<(), Error>
[src]

Writes the instructions bytes to the passed rom. If an expr in the instruction uses an identifier than it looks up the value for it in constants. Will return Err if constants doesn't contain the required label.

pub fn len(&self, start_address: u16) -> u16[src]

Returns how many bytes the instruction takes up

Trait Implementations

impl Clone for Instruction[src]

impl Debug for Instruction[src]

impl PartialEq<Instruction> for Instruction[src]

impl StructuralPartialEq for Instruction[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

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

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

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

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

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

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.