triton-tui 3.0.0

Terminal User Interface to help debugging programs written for Triton VM.
//! 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