Skip to content

Commit

Permalink
implement opcode fromaltstack
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavek committed Jul 26, 2024
1 parent 6e00f2e commit a4c8ac0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/compiler.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down
9 changes: 8 additions & 1 deletion src/opcodes/opcodes.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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);
}
}

0 comments on commit a4c8ac0

Please sign in to comment.