commit 583b1e743a9e1da9b5405e104049a1674382512c
parent 7e58ad3d90671acdfb916c029c20f648dbb8e421
Author: Pavel Renev <an2qzavok@gmail.com>
Date: Sat, 27 Mar 2021 20:52:09 +0000
forgot to commit vsm.h
Diffstat:
A | vsm.h | | | 81 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 81 insertions(+), 0 deletions(-)
diff --git a/vsm.h b/vsm.h
@@ -0,0 +1,81 @@
+#define CELL s32int
+#define IMAGE_SIZE 64 * 1024
+#define STACK_DEPTH 512
+typedef void (*instruction)(void);
+
+/* Operators */
+
+enum {
+ VSM_NOP,
+/* ALU: */
+ VSM_ADD, VSM_SUB, VSM_AND, VSM_OR, VSM_XOR,
+/* Stack Manipulation: */
+ VSM_DROP, VSM_DUP, VSM_OVER, VSM_SWAP, VSM_TOR, VSM_FROMR,
+/* Memory Management: */
+ VSM_STORE, VSM_FETCH,
+/* Literals: */
+ VSM_LIT,
+/* Conditional Branching: */
+ VSM_IF,
+/* Subroutine Calls: */
+ VSM_CALL, VSM_EXIT,
+};
+
+#define NUM_OPS VSM_EXIT + 1
+
+CELL pc;
+CELL ir;
+
+/* Stack */
+
+CELL dstack[STACK_DEPTH], *dsp;
+CELL rstack[STACK_DEPTH], *rsp;
+
+/* Program Memory */
+
+CELL mar;
+CELL ram[IMAGE_SIZE];
+
+/* Input/Output */
+
+
+/* Instructions */
+
+void i_NOP(void);
+
+/* ALU: */
+void i_ADD(void);
+void i_SUB(void);
+void i_AND(void);
+void i_OR(void);
+void i_XOR(void);
+
+/* Stack Manipulation: */
+void i_DROP(void);
+void i_DUP(void);
+void i_OVER(void);
+void i_SWAP(void);
+void i_TOR(void);
+void i_FROMR(void);
+
+/* Memory Management: */
+void i_STORE(void);
+void i_FETCH(void);
+
+/* Literals: */
+void i_LIT(void);
+
+/* Conditional Branching: */
+void i_IF(void);
+
+/* Subroutine Calls: */
+void i_CALL(void);
+void i_EXIT(void);
+
+/* VMS Control */
+
+void vsm_exec(CELL);
+void vsm_halt(void);
+int vsm_readimage(char*);
+void vsm_reset(void);
+void vsm_run(void);