Similar to branching (bnz, bz etc) is there a way to do conditional callsubs (or retsubs) or can you offer a technique to accomplish the same?
e.g.
load 1
pushint 0
“>” // quotes just added for formatting bnz callsub dothis1
// retsub inside dothis1 would return here, and continue below
// itoa
itoa_1:
store 0
load 0
int 0
==
bnz itoa_1_l5
load 0
int 10
/
int 0
>
bnz itoa_1_l4
byte ""
itoa_1_l3:
load 0
int 10
%
callsub inttoascii_0
concat
b itoa_1_l6
itoa_1_l4:
load 0
int 10
/
load 0
swap
callsub itoa_1
swap
store 0
b itoa_1_l3
itoa_1_l5:
byte "0"
itoa_1_l6:
retsub
Here there is a label at the end that handles retsub, if at any point you want to return from the subroutine you can branch to itoa_1_l6 and itll return, otherwise the evaluation will continue inline.
The above was generated with PyTeal which I’ve found is a nice way to see how traditional flow paradigms might look in TEAL.