Skip to content

Commit

Permalink
Fix brainfuck
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Nov 7, 2024
1 parent dbdd1e1 commit 284872c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions programs/benches/brainfuck.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use core::{
traits::Default,
array::{ArrayTrait, SpanTrait}, debug::PrintTrait, dict::Felt252DictTrait,
integer::{u8_wrapping_add, u8_wrapping_sub}, option::OptionTrait, traits::Into,
option::OptionTrait, traits::Into,
num::traits::{WrappingAdd, WrappingSub},
};

fn generate_jump_table(program: @Array<u8>) -> Felt252Dict<u32> {
Expand Down Expand Up @@ -50,9 +51,9 @@ fn run_program(program: @Array<u8>, input: Option<Span<u8>>) {
} else if op_code == '<' {
mp -= 1;
} else if op_code == '+' {
memory.insert(mp, u8_wrapping_add(memory.get(mp), 1));
memory.insert(mp, memory.get(mp).wrapping_add(1));
} else if op_code == '-' {
memory.insert(mp, u8_wrapping_sub(memory.get(mp), 1));
memory.insert(mp, memory.get(mp).wrapping_sub(1));
} else if op_code == '.' {
memory.get(mp).print();
} else if op_code == ',' {
Expand Down

0 comments on commit 284872c

Please sign in to comment.