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,