Hi pheathwa,
You can definitely do conditional callsub/retsub.
Consider the following TEAL
// 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.
Ben