Skip to content

Commit

Permalink
Merge pull request #183 from 0xPolygonMiden/dominik_update_examples
Browse files Browse the repository at this point in the history
changing MASM u32 calls
  • Loading branch information
Dominik1999 authored Apr 30, 2024
2 parents 6e02537 + e71ee21 commit 687ea58
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/catalan.masm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ proc.catalan_i
dup.1
# Need to use u32 division to truncate properly
# Safe to use unchecked, since k < i <= n+1, and n+1 has been asserted as u32
u32unchecked_div.2
u32div.2
# [ k/2, running_total, k, i, ... ]
# Initialize counter
push.0
Expand Down
2 changes: 1 addition & 1 deletion examples/collatz.masm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ begin
swap push.1 add swap

# actual check
dup push.2 u32checked_mod
dup push.2 u32assert2 u32mod
if.true
push.3 mul push.1 add
else
Expand Down
2 changes: 1 addition & 1 deletion examples/matrix_multiplication.masm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
proc.count_to_word.0
# input: [length, ...]
# output: [word_count, ...]
u32checked_divmod.4 eq.0 not add
u32assert2 u32divmod.4 eq.0 not add
end

# multiply_add_word(a: Word, b: Word) -> Felt
Expand Down
2 changes: 1 addition & 1 deletion examples/nprime.masm
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ proc.is_not_prime_should_continue
# [remainder, continue loop?, is prime?, prime, j, candidate, i, n, primes..]
dup.4
dup.3
u32checked_mod
u32assert2 u32mod

# if remainder is zero, then the number is divisible by prime; hence isn't prime
# [continue loop?, is prime?, prime, j, candidate, i, n, primes..]
Expand Down
4 changes: 3 additions & 1 deletion examples/standard_library.inputs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"operand_stack": [""]
}
8 changes: 4 additions & 4 deletions playground/miden-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@ fn test_run_program_with_std_lib() {
"use.std::math::u64
begin
push.1.0
push.2.0
exec.u64::checked_add
push.1
push.2
exec.u64::max
end",
"",
)
.unwrap();
assert_eq!(
output.stack_output,
vec![0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
vec![2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
);
assert_eq!(output.trace_len, Some(64));
}
Expand Down
12 changes: 6 additions & 6 deletions playground/src/components/DropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ const examples = [
'addition',
'conditional',
'fibonacci',
'standard_library',
'game_of_life_4x4',
'catalan',
'dft',
'shamir_secret_share',
//'bsearch',
//'collatz',
//'comparison',
//'matrix_multiplication',
//'nprime',
//'standard_library',
'collatz',
'comparison',
'matrix_multiplication',
'nprime',
//'advice_provider',
//'bsearch',
];

function classExamples(...classes: string[]) {
Expand Down

0 comments on commit 687ea58

Please sign in to comment.