forked from skx/simple.vm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom.in
More file actions
43 lines (34 loc) · 645 Bytes
/
Copy pathrandom.in
File metadata and controls
43 lines (34 loc) · 645 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
40
41
42
43
#
# About
#
# Output ten random integers.
#
#
# Usage
#
# $ compiler ./random.in ; ./simple-vm ./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