Skip to content

Commit

Permalink
Updated usage information for each script
Browse files Browse the repository at this point in the history
  • Loading branch information
skx committed Jul 1, 2018
1 parent 35d37c3 commit ea1f637
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 58 deletions.
10 changes: 6 additions & 4 deletions examples/add.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program adds two numbers.
#
# Usage:
#
# Usage
#
# $ compiler ./add.in ; ./simple-vm ./add.raw
# $ go.vm run ./add.in
#
# Or compile, then execute:
#
# $ go.vm compile ./add.in
# $ go.vm execute ./add.raw
#

store #1, 10
Expand All @@ -18,4 +20,4 @@

# add newline to the output
store #1, "\n"
print_str #1
print_str #1
11 changes: 7 additions & 4 deletions examples/call.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
#
# This program demonstrates that we can use subroutines.
#
# Usage:
#
# Usage
#
# $ compiler ./call.in ; ./simple-vm ./call.raw
# $ go.vm run ./call.in
#
# Or compile, then execute:
#
# $ go.vm compile ./call.in
# $ go.vm execute ./call.raw
#

store #1, 15
call print

Expand All @@ -33,4 +36,4 @@
print_int #1
store #1, "\n"
print_str #1
ret
ret
10 changes: 6 additions & 4 deletions examples/compare.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program compares the number in a register with a constant.
#
# Usage:
#
# Usage
#
# $ compiler ./compare.in ; ./simple-vm ./compare.raw
# $ go.vm run ./compare.in
#
# Or compile, then execute:
#
# $ go.vm compile ./compare.in
# $ go.vm execute ./compare.raw
#

store #1, 44
Expand Down Expand Up @@ -45,4 +47,4 @@
:str2
store #1, "String comparisions OK\n"
print_str #1
exit
exit
8 changes: 5 additions & 3 deletions examples/concat.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# Use a conditional jump to loop ten times, building up a string as we go.
#
# Usage:
#
# Usage
#
# $ compiler ./concat.in ; ./simple-vm ./concat.raw
# $ go.vm run ./concat.in
#
# Or compile, then execute:
#
# $ go.vm compile ./concat.in
# $ go.vm execute ./concat.raw
#

store #1, "Counting bananas"
Expand Down
10 changes: 6 additions & 4 deletions examples/dec.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program decrements an integer.
#
# Usage:
#
# Usage
#
# $ compiler ./dec.in ; ./simple-vm ./dec.raw
# $ go.vm run ./dec.in
#
# Or compile, then execute:
#
# $ go.vm compile ./dec.in
# $ go.vm execute ./dec.raw
#

store #1, 3
Expand Down Expand Up @@ -37,4 +39,4 @@
jmpz empty

:empty
exit
exit
10 changes: 6 additions & 4 deletions examples/equal.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program tests our comparision operation.
#
# Usage:
#
# Usage
#
# $ compiler ./equal.in ; ./simple-vm ./equal.raw
# $ go.vm run ./equal.in
#
# Or compile, then execute:
#
# $ go.vm compile ./equal.in
# $ go.vm execute ./equal.raw
#

store #1, 20
Expand All @@ -31,4 +33,4 @@
:twenty_eq_thirty
store #0, "20 == 30 - Bug!\n"
print_str #0
exit
exit
18 changes: 16 additions & 2 deletions examples/hello.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
#
# About
#
# This program prints the traditional greeting.
#
# Usage:
#
# $ go.vm run ./hello.in
#
# Or compile, then execute:
#
# $ go.vm compile ./hello.in
# $ go.vm execute ./hello.raw
#

store #1, "Hello, World!\n"
print_str #1
store #1, "Hello, World!\n"
print_str #1
exit
9 changes: 5 additions & 4 deletions examples/jump.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
#
# However it does prove that the goto/label handling is correct.
#
# Usage:
#
# Usage
#
# $ compiler ./jump.in ; ./simple-vm ./jump.raw
# $ go.vm run ./jump.in
#
# Or compile, then execute:
#
# $ go.vm compile ./jump.in
# $ go.vm execute ./jump.raw
#

store #1, "Steve Kemp\n"
Expand All @@ -35,4 +37,3 @@
print_str #1

goto kirsi

8 changes: 5 additions & 3 deletions examples/loop.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
# Use a conditional jump to loop ten times, the conditional will trigger
# if a "SUB" operation results in <0.
#
# Usage:
#
# Usage
#
# $ compiler ./loop.in ; ./simple-vm ./loop.raw
# $ go.vm run ./loop.in
#
# Or compile, then execute:
#
# $ go.vm compile ./loop.in
# $ go.vm execute ./loop.raw
#

store #1, "Counting from ten to zero\n"
Expand Down
14 changes: 14 additions & 0 deletions examples/math.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
#
# About
#
# This program demonstrates the use of bitwise AND and XOR operations.
#
# Usage:
#
# $ go.vm run ./math.in
#
# Or compile, then execute:
#
# $ go.vm compile ./math.in
# $ go.vm execute ./math.raw
#

store #1, "255 & 16 is : "
print_str #1
Expand Down
8 changes: 5 additions & 3 deletions examples/memcpy.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program copies a bunch of memory about, then jumps to it.
#
# Usage:
#
# Usage
#
# $ compiler ./memcpy.in ; ./simple-vm ./memcpy.raw
# $ go.vm run ./memcpy.in
#
# Or compile, then execute:
#
# $ go.vm compile ./memcpy.in
# $ go.vm execute ./memcpy.raw
#

goto run
Expand Down
8 changes: 5 additions & 3 deletions examples/mul.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program multiples and divides two numbers.
#
# Usage:
#
# Usage
#
# $ compiler ./mul.in ; ./simple-vm ./mul.raw
# $ go.vm run ./mul.in
#
# Or compile, then execute:
#
# $ go.vm compile ./mul.in
# $ go.vm execute ./mul.raw
#

store #1, 10
Expand Down
10 changes: 6 additions & 4 deletions examples/poke.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
#
# About
#
# Show some opcodes in RAM, then execute them.
# POKE some opcodes in RAM, then execute them.
#
# Usage:
#
# Usage
#
# $ compiler ./poke.in ; ./simple-vm ./poke.raw
# $ go.vm run ./poke.in
#
# Or compile, then execute:
#
# $ go.vm compile ./poke.in
# $ go.vm execute ./poke.raw
#

#
Expand Down
8 changes: 5 additions & 3 deletions examples/quine.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# Show the binary opcodes of this program!
#
# Usage:
#
# Usage
#
# $ compiler ./quine.in ; ./simple-vm ./quine.raw
# $ go.vm run ./quine.in
#
# Or compile, then execute:
#
# $ go.vm compile ./quine.in
# $ go.vm execute ./quine.raw
#

#
Expand Down
8 changes: 5 additions & 3 deletions examples/random.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# Output ten random integers.
#
# Usage:
#
# Usage
#
# $ compiler ./random.in ; ./simple-vm ./random.raw
# $ 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"
Expand Down
10 changes: 6 additions & 4 deletions examples/stack.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program demonstrates that the stack can be used to store integers.
#
# Usage:
#
# Usage
#
# $ compiler ./stack.in ; ./simple-vm ./stack.raw
# $ go.vm run ./stack.in
#
# Or compile, then execute:
#
# $ go.vm compile ./stack.in
# $ go.vm execute ./stack.raw
#

#
Expand Down Expand Up @@ -45,4 +47,4 @@
# Success.
store #0, "Stack operation was successful\n"
print_str #0
exit
exit
8 changes: 5 additions & 3 deletions examples/system.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program just executes /bin/ls.
#
# Usage:
#
# Usage
#
# $ compiler ./system.in ; ./simple-vm ./system.raw
# $ go.vm run ./system.in
#
# Or compile, then execute:
#
# $ go.vm compile ./system.in
# $ go.vm execute ./system.raw
#

store #1, "/bin/ls"
Expand Down
16 changes: 16 additions & 0 deletions examples/trap.stdin.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#
# About:
#
# This program demonstrates the use of `int 0x01` to read a string from
# STDIN, via a trap to the CPU.
#
# Usage:
#
# $ go.vm run ./trap.stdin.in
#
# Or compile, then execute:
#
# $ go.vm compile ./trap.stdin.in
# $ go.vm execute ./trap.stdin.raw
#

store #1, "Enter a string:"
print_str #1

Expand Down
8 changes: 5 additions & 3 deletions examples/types.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
#
# This program tests our type-handling - which is basic.
#
# Usage:
#
# Usage
#
# $ compiler ./types.in ; ./simple-vm ./types.raw
# $ go.vm run ./types.in
#
# Or compile, then execute:
#
# $ go.vm compile ./types.in
# $ go.vm execute ./types.raw
#

store #1, 43
Expand Down

0 comments on commit ea1f637

Please sign in to comment.