Enum ggbasm::ast::Instruction
source · pub enum Instruction {
Show 105 variants
EmptyLine,
AdvanceAddress(u16),
Equ(String, Expr),
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(Flag, Expr),
JpI16(Flag, Expr),
JpRhl,
Jr(Flag, Expr),
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(Reg16, Expr),
LdMI16Rsp(Expr),
LdMRbcRa,
LdMRdeRa,
LdRaMRbc,
LdRaMRde,
LdR8R8(Reg8, Reg8),
LdR8I8(Reg8, Expr),
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(Expr, Reg8),
BitBitMRhl(Expr),
ResBitR8(Expr, Reg8),
ResBitMRhl(Expr),
SetBitR8(Expr, Reg8),
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(String, Expr)
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(Flag, Expr)
JpI16(Flag, Expr)
JpRhl
Jr(Flag, Expr)
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(Reg16, Expr)
LdMI16Rsp(Expr)
LdMRbcRa
LdMRdeRa
LdRaMRbc
LdRaMRde
LdR8R8(Reg8, Reg8)
LdR8I8(Reg8, Expr)
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(Expr, Reg8)
BitBitMRhl(Expr)
ResBitR8(Expr, Reg8)
ResBitMRhl(Expr)
SetBitR8(Expr, Reg8)
SetBitMRhl(Expr)
Implementations§
source§impl Instruction
impl Instruction
sourcepub fn write_to_rom(
&self,
rom: &mut Vec<u8>,
constants: &HashMap<String, i64>
) -> Result<(), Error>
pub fn write_to_rom(
&self,
rom: &mut Vec<u8>,
constants: &HashMap<String, i64>
) -> Result<(), Error>
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.
Trait Implementations§
source§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more