special-cased BRC
This commit is contained in:
parent
6791b6d48e
commit
4dfbe93919
|
@ -16,7 +16,7 @@ macros::impl_both!(
|
|||
bbbb(p0: R, p1: R, p2: R, p3: R)
|
||||
=> [DIR, DIRF, FMAF],
|
||||
bbb(p0: R, p1: R, p2: R)
|
||||
=> [ADD, SUB, MUL, AND, OR, XOR, SL, SR, SRS, CMP, CMPU, BRC, ADDF, SUBF, MULF],
|
||||
=> [ADD, SUB, MUL, AND, OR, XOR, SL, SR, SRS, CMP, CMPU, /*BRC,*/ ADDF, SUBF, MULF],
|
||||
bbdh(p0: R, p1: R, p2: I, p3: u16)
|
||||
=> [LD, ST],
|
||||
bbd(p0: R, p1: R, p2: I)
|
||||
|
@ -30,6 +30,14 @@ macros::impl_both!(
|
|||
=> [NOP, ECALL],
|
||||
);
|
||||
|
||||
impl Assembler {
|
||||
// Special-cased
|
||||
#[inline(always)]
|
||||
pub fn i_brc(&mut self, p0: u8, p1: u8, p2: u8) {
|
||||
self.i_param_bbb(hbbytecode::opcode::BRC, p0, p1, p2)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Imm {
|
||||
fn insert(&self, asm: &mut Assembler);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ macro_rules! impl_asm_opcodes {
|
|||
=> [$opcode:ident, $($rest:tt)*]
|
||||
) => {
|
||||
paste::paste! {
|
||||
#[allow(dead_code)]
|
||||
#[inline(always)]
|
||||
pub fn [<i_ $opcode:lower>](&mut self, $($param_i: $param_ty),*) {
|
||||
self.$generic(hbbytecode::opcode::$opcode, $($param_i),*)
|
||||
|
@ -45,7 +44,6 @@ macro_rules! impl_asm {
|
|||
) => {
|
||||
paste::paste! {
|
||||
$(
|
||||
#[allow(dead_code)]
|
||||
fn [<i_param_ $ityn>](&mut self, opcode: u8, $($param_i: macros::asm::ident_map_ty!($param_ty)),*) {
|
||||
self.buf.push(opcode);
|
||||
$(macros::asm::impl_asm_insert!(self, $param_i, $param_ty);)*
|
||||
|
|
|
@ -24,6 +24,7 @@ macro_rules! gen_text {
|
|||
#[logos(skip r"-- .*")]
|
||||
pub enum Token {
|
||||
$($(#[token(~([<$opcode:lower>]), |_| hbbytecode::opcode::[<$opcode:upper>])])*)*
|
||||
#[token("brc", |_| hbbytecode::opcode::BRC)] // Special-cased
|
||||
Opcode(u8),
|
||||
|
||||
#[regex("[0-9]+", |l| l.slice().parse().ok())]
|
||||
|
@ -100,6 +101,17 @@ macro_rules! gen_text {
|
|||
self.asm.[<i_param_ $ityn>](op, $($param_i),*);
|
||||
}),
|
||||
)*
|
||||
// Special-cased
|
||||
hbbytecode::opcode::BRC => {
|
||||
param_extract_itm!(
|
||||
self,
|
||||
p0: R,
|
||||
p1: R,
|
||||
p2: u8
|
||||
);
|
||||
|
||||
self.asm.i_param_bbb(op, p0, p1, p2);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +178,7 @@ macro_rules! gen_text {
|
|||
macro_rules! extract_pat {
|
||||
($self:expr, $pat:pat) => {
|
||||
let $pat = $self.next()?
|
||||
else { return Err(ErrorKind::UnexpectedToken) };
|
||||
else { return Err(ErrorKind::UnexpectedToken) };
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -183,6 +195,11 @@ macro_rules! extract {
|
|||
};
|
||||
};
|
||||
|
||||
($self:expr, u8, $id:ident) => {
|
||||
extract_pat!($self, Token::Integer($id));
|
||||
let $id = u8::try_from($id).map_err(|_| ErrorKind::InvalidToken)?;
|
||||
};
|
||||
|
||||
($self:expr, u16, $id:ident) => {
|
||||
extract_pat!($self, Token::Integer($id));
|
||||
let $id = u16::try_from($id).map_err(|_| ErrorKind::InvalidToken)?;
|
||||
|
|
Loading…
Reference in a new issue