Created
June 6, 2022 08:16
-
-
Save Th0rgal/f77d40df331ad60483c894e90da46299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%builtins output | |
from starkware.cairo.common.serialize import serialize_word | |
from starkware.cairo.common.alloc import alloc | |
func print_words{output_ptr : felt*}(res_len : felt, res : felt*): | |
if res_len == 0: | |
return () | |
end | |
serialize_word([res]) | |
print_words(res_len - 1, res + 1) | |
return () | |
end | |
func main{output_ptr : felt*}(): | |
alloc_locals | |
let (local arr) = alloc() | |
const loop_size = 5 | |
const loop_space = 4 | |
[ap] = loop_size; ap++ | |
loop: | |
# do stuff here | |
assert arr[loop_size - [ap - 1]] = 1 | |
# loop | |
[ap] = [ap - 1 - loop_space] - 1; ap++ | |
jmp loop if [ap - 1] != 0 | |
print_words(loop_size, arr) | |
return () | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment