forked from skx/simple.vm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.in
48 lines (42 loc) · 846 Bytes
/
stack.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
46
47
48
#
# About
#
# This program demonstrates that the stack can be used to store integers.
#
#
# Usage
#
# $ compiler ./stack.in ; ./simple-vm ./stack.raw
#
#
#
#
# Store an integer, then push to the stack.
#
store #1, 2234
push #1
#
# Store a different integer.
#
store #1, 65535
#
# POP from the stack - so we're back where we were.
#
pop #1
#
# Ensure we're _really_ there, because the expected value
# has been returned.
#
cmp #1, 2234
jmpz ok
#
# Boo - Failure.
#
store #0, "Error - stack push/pop mismatch\n"
print_str #0
exit
:ok
# Success.
store #0, "Stack operation was successful\n"
print_str #0
exit