From 9a99445dcb5a6dac98f6650ff0015062cea010ce Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 18 Oct 2024 20:25:58 +0200 Subject: [PATCH] asm: add forms to call and exec macros --- src/isa/macros.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/isa/macros.rs b/src/isa/macros.rs index 462aa20..e07ca3c 100644 --- a/src/isa/macros.rs +++ b/src/isa/macros.rs @@ -23,8 +23,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::isa::ControlFlowOp; - /// Macro compiler for AluVM assembler. /// /// # Example @@ -97,6 +95,10 @@ macro_rules! aluasm_inner { $code.push($crate::instr!{ $op }); $crate::aluasm_inner! { $code => $( $tt )* } }; + { $code:ident => $op:ident $arg:literal @ $lib:ident ; $($tt:tt)* } => { + $code.push($crate::instr!{ $op $arg @ $lib }); + $crate::aluasm_inner! { $code => $( $tt )* } + }; { $code:ident => $op:ident $arg:literal @ $lib:literal ; $($tt:tt)* } => { $code.push($crate::instr!{ $op $arg @ $lib }); $crate::aluasm_inner! { $code => $( $tt )* } @@ -186,12 +188,24 @@ macro_rules! instr { (routine $offset:ident) => { Instr::ControlFlow(ControlFlowOp::Routine($offset)) }; + (call $offset:literal @ $lib:ident) => { + Instr::ControlFlow(ControlFlowOp::Call(LibSite::with( + $offset, + $lib + ))) + }; (call $offset:literal @ $lib:literal) => { Instr::ControlFlow(ControlFlowOp::Call(LibSite::with( $offset, $lib.parse().expect("wrong library reference"), ))) }; + (exec $offset:literal @ $lib:ident) => { + Instr::ControlFlow(ControlFlowOp::Exec(LibSite::with( + $offset, + $lib + ))) + }; (call $offset:ident @ $lib:ident) => { Instr::ControlFlow(ControlFlowOp::Call(LibSite::with( $offset,