-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.sam
More file actions
39 lines (28 loc) · 853 Bytes
/
input.sam
File metadata and controls
39 lines (28 loc) · 853 Bytes
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
@main
print: # print a string to console
putchar dup ^print pop ret
newline: # print a newline to console
10 putchar ret
fizzbuzz: # run fizzbuzz from 1 to the input argument
1 swap dup 1
fizzbuzz_start:
> ^fizzbuzz_leave
fizzbuzz_loop:
swap
dup 3 % ^fizzbuzz_skip_one # check divisibility by 3
"Fizz" @print
fizzbuzz_skip_one:
dup 5 % ^fizzbuzz_skip_two # check divisibility by 5
"Buzz" @print
fizzbuzz_skip_two:
dup 5 % ! ^fizzbuzz_skip_three # check divisibility by 15
dup 3 % ! ^fizzbuzz_skip_three
dup log
fizzbuzz_skip_three:
@newline
1 + swap ddup swap
&fizzbuzz_start
fizzbuzz_leave:
ret
main:
50 @fizzbuzz # call fizzbuzz