forked from skx/go.vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
random.in
45 lines (36 loc) · 709 Bytes
/
random.in
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
40
41
42
43
44
45
#
# About
#
# Output ten random integers.
#
# Usage:
#
# $ go.vm run ./random.in
#
# Or compile, then execute:
#
# $ go.vm compile ./random.in
# $ go.vm execute ./random.raw
#
store #1, "Generating ten random integers\n"
print_str #1
store #1, 10
store #2, 1
:repeat
#
# This means "reg1 = reg1 - reg2"
#
sub #1, #1, #2
# output the random number
random #5
print_int #5
# add newline to the output
store #5, "\n"
print_str #5
#
# This jump only occur if the zero-flag is set.
#
jmpnz repeat
store #1, "Done\n"
print_str #1
exit