Adding a 'Hello, World!' example using stdlib and a new build
authorAaron Taylor <ataylor@subgeniuskitty.com>
Thu, 11 Jul 2019 12:26:18 +0000 (05:26 -0700)
committerAaron Taylor <ataylor@subgeniuskitty.com>
Thu, 11 Jul 2019 12:26:18 +0000 (05:26 -0700)
system using `cpp`.

examples/Makefile [new file with mode: 0644]
examples/config.mk [new file with mode: 0644]
examples/hello-stdlib/Makefile [new file with mode: 0644]
examples/hello-stdlib/hello.pvvs
examples/hello-world/Makefile [new file with mode: 0644]
stdlib/stdio.pvvs

diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644 (file)
index 0000000..cb5ac3d
--- /dev/null
@@ -0,0 +1,14 @@
+# (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
+# All rights reserved.
+
+EXAMPLES != find . -mindepth 1 -maxdepth 1 -type d
+
+all:
+       @echo "No target available to build all."
+       @echo "Try 'make run' inside an example folder."
+
+clean:
+       @for dir in $(EXAMPLES); do \
+               echo Cleaning $$dir; \
+               (cd $$dir; ${MAKE} clean); \
+       done
diff --git a/examples/config.mk b/examples/config.mk
new file mode 100644 (file)
index 0000000..19bc033
--- /dev/null
@@ -0,0 +1,11 @@
+# (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
+# All rights reserved.
+
+####################################################################################################
+# Configuration
+
+VVS_COMPILER   = ../../vvc
+VVS_INTERPRETER        = ../../vvi
+
+CPP            = cpp
+CPP_FLAGS      = -I../../stdlib
diff --git a/examples/hello-stdlib/Makefile b/examples/hello-stdlib/Makefile
new file mode 100644 (file)
index 0000000..b8609e1
--- /dev/null
@@ -0,0 +1,17 @@
+# (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
+# All rights reserved.
+
+include ../config.mk
+
+all: hello
+
+hello:
+       $(CPP) $(CPP_FLAGS) -o temp.pvvs hello.pvvs
+       $(VVS_COMPILER) -i temp.pvvs -o hello.vvs
+       @rm -f temp.pvvs
+
+run:
+       $(VVS_INTERPRETER) -i hello.vvs
+
+clean:
+       @rm -f hello.vvs temp.pvvs
index 628fa7e..c0ddb0d 100644 (file)
@@ -1,4 +1,4 @@
-## This program outputs "Hello, world!"
+@@ This program outputs "Hello, world!"
 
 SSSSN           | ST: Push +0 (ASCII '\0')
 SSSTSSSSTN      | ST: Push +33 (ASCII !)
 
 SSSSN           | ST: Push +0 (ASCII '\0')
 SSSTSSSSTN      | ST: Push +33 (ASCII !)
@@ -16,3 +16,5 @@ SSSTTSSTSTN     | ST: Push +101 (ASCII e)
 SSSTSSTSSSN     | ST: Push +72 (ASCII H)
 NSTTSSSN        | FC: JSR>1000 (print string from stack; see stdlib)
 NNN             | FC: Terminate program
 SSSTSSTSSSN     | ST: Push +72 (ASCII H)
 NSTTSSSN        | FC: JSR>1000 (print string from stack; see stdlib)
 NNN             | FC: Terminate program
+
+#include "stdio.pvvs"
diff --git a/examples/hello-world/Makefile b/examples/hello-world/Makefile
new file mode 100644 (file)
index 0000000..32f38a7
--- /dev/null
@@ -0,0 +1,15 @@
+# (c) 2019 Aaron Taylor <ataylor at subgeniuskitty dot com>
+# All rights reserved.
+
+include ../config.mk
+
+all: hello
+
+hello:
+       $(VVS_COMPILER) -i hello.pvvs -o hello.vvs
+
+run:
+       $(VVS_INTERPRETER) -i hello.vvs
+
+clean:
+       @rm -f hello.vvs
index d9184ad..03c60c7 100644 (file)
@@ -1,15 +1,18 @@
-################################################################################
-# Description:
-#   This function prints a null-terminated string from the stack.
-# Call Stack:
-#   null-terminator (ASCII '\0')
-#   char n
-#   ...
-#   char 2
-#   char 1 <-- TOS
-# Return Stack:
-#   <empty>
-################################################################################
+#ifndef VVS_STDLIB_STDIO
+#define VVS_STDLIB_STDIO
+
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Description:
+@   This function prints a null-terminated string from the stack.
+@ Call Stack:
+@   null-terminator (ASCII '\0')
+@   char n
+@   ...
+@   char 2
+@   char 1 <-- TOS
+@ Return Stack:
+@   <empty>
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 NSSVTSSSN               | Mark: 1000 (print string from stack)
 SNS                     | DUP
 NTSSSSSTSSSSSSSSSSTN    | BRZ > 00001000 00000001
 NSSVTSSSN               | Mark: 1000 (print string from stack)
 SNS                     | DUP
 NTSSSSSTSSSSSSSSSSTN    | BRZ > 00001000 00000001
@@ -19,14 +22,14 @@ NSSVSSSSTSSSSSSSSSSTN   | Mark: 00001000 00000001
 SNN                     | DROP
 NTN                     | RTS
 
 SNN                     | DROP
 NTN                     | RTS
 
-################################################################################
-# Description:
-#   This function prints a null-terminated string from the heap.
-# Call Stack:
-#   pointer to first character  <-- TOS
-# Return Stack:
-#   <empty>
-################################################################################
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+@ Description:
+@   This function prints a null-terminated string from the heap.
+@ Call Stack:
+@   pointer to first character  <-- TOS
+@ Return Stack:
+@   <empty>
+@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 NSSVTSSTN               | Mark: 1001 (print string from heap)
 SNS                     | DUP
 TTT                     | LOAD
 NSSVTSSTN               | Mark: 1001 (print string from heap)
 SNS                     | DUP
 TTT                     | LOAD
@@ -40,3 +43,5 @@ NSSVSSSSTSSTSSSSSSSTN   | Mark: 00001001 00000001
 SNN                     | DROP
 SNN                     | DROP
 NTN                     | RTS
 SNN                     | DROP
 SNN                     | DROP
 NTN                     | RTS
+
+#endif