From a4c8ac016deecb625370dc0bf042ba690b15a15d Mon Sep 17 00:00:00 2001 From: Xavek Date: Fri, 26 Jul 2024 22:24:10 +0545 Subject: [PATCH] implement opcode fromaltstack --- src/compiler.cairo | 1 + src/opcodes/opcodes.cairo | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler.cairo b/src/compiler.cairo index 6444ac72..8453ad29 100644 --- a/src/compiler.cairo +++ b/src/compiler.cairo @@ -40,6 +40,7 @@ pub impl CompilerTraitImpl of CompilerTrait { opcodes.insert('OP_1ADD', Opcode::OP_1ADD); opcodes.insert('OP_ADD', Opcode::OP_ADD); opcodes.insert('OP_MAX', Opcode::OP_MAX); + opcodes.insert('OP_FROMALTSTACK', Opcode::OP_FROMALTSTACK); Compiler { opcodes } } diff --git a/src/opcodes/opcodes.cairo b/src/opcodes/opcodes.cairo index 6354b3e1..df54fca9 100644 --- a/src/opcodes/opcodes.cairo +++ b/src/opcodes/opcodes.cairo @@ -21,6 +21,7 @@ pub mod Opcode { pub const OP_1ADD: u8 = 139; pub const OP_ADD: u8 = 147; pub const OP_MAX: u8 = 164; + pub const OP_FROMALTSTACK: u8 = 108; use shinigami::engine::Engine; use shinigami::stack::ScriptStackTrait; @@ -134,7 +135,7 @@ pub mod Opcode { 105 => not_implemented(ref engine), 106 => not_implemented(ref engine), 107 => not_implemented(ref engine), - 108 => not_implemented(ref engine), + 108 => opcode_fromaltstack(ref engine), 109 => not_implemented(ref engine), 110 => not_implemented(ref engine), 111 => not_implemented(ref engine), @@ -234,4 +235,10 @@ pub mod Opcode { b }); } + + fn opcode_fromaltstack(ref engine: Engine) { + //TODO: Error handling + let a = engine.astack.pop_byte_array(); + engine.dstack.push_byte_array(a); + } }