Enum ggbasm::ast::Instruction

source ·
pub enum Instruction {
Show 105 variants 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),
}
Expand description

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)

§

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)

Implementations§

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.

Returns how many bytes the instruction takes up

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Sets value as a parameter of self.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.