-
Notifications
You must be signed in to change notification settings - Fork 0
/
program.tasm
71 lines (61 loc) · 1.93 KB
/
program.tasm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Demonstrates use and functionality of the Triton VM TUI.
//!
//! Serves as the tutorial: execution intentionally fails at first, hopefully
//! encouraging you to play around. :) The inline comments should make matters trivial.
//!
//! Press `h` in Triton VM TUI to show the help screen.
// Let's start!
push 3
hint loop_counter = stack[0] // Current stack can be annotated to help debugging.
break
call my_loop
hint numbers: array = stack[1..4] // Annotations also work with ranges.
call check_result
call write_to_memory
call read_from_secret_input
call recursive_function
call sponge_instructions
halt
my_loop:
dup 0 push 0 eq skiz return
read_io 3 // call with `--input ./public_input.txt`
mul mul
break
dup 0 write_io 1
swap 1 push -1 add recurse
check_result: // Try enabling
// pop 1 // <- this line for
assert error_id -17 // <- this assertion to work.
return // Hot reload & reset of the VM is `r`.
write_to_memory:
push 42
write_mem 2 // You can inspect memory with `m`.
pop 1
return
read_from_secret_input:
divine 3 // flag `--non-determinism ./non_determinism.json`
mul mul
swap 5
merkle_step
merkle_step
return
sponge_instructions:
sponge_init // Show the Sponge state with `t,s`.
push 42
sponge_absorb_mem // to absorb stack elements, use `sponge_absorb`
pop 1
sponge_squeeze
return
recursive_function:
// set up for recursion
push 0 swap 5
hint loop_counter = stack[5]
push 3 swap 5
hint termination_condition = stack[5]
call actual_recursion_loop
return
actual_recursion_loop:
// change loop counter to eventually reach termination condition
swap 6 push 1 add swap 6
// do some meaningful work here
recurse_or_return