Permalink
Browse files

Inital commit of quick and dirty lorito.

  • Loading branch information...
0 parents commit e486e74cc5177b31ff7786686b91ab940b05e302 @atrodo committed Jul 8, 2010
Showing with 165 additions and 0 deletions.
  1. +8 −0 config.h
  2. +58 −0 core.c
  3. +3 −0 loader.c
  4. +58 −0 lorito.h
  5. +6 −0 main.c
  6. +32 −0 microcode.h
@@ -0,0 +1,8 @@
+// All of the config and compile options. Yea, I'll get to it.
+
+#ifndef LORITO_CONFIG_H_GUARD
+#define LORITO_CONFIG_H_GUARD
+
+#define REGNUM 32
+
+#endif /* LORITO_CONFIG_H_GUARD */
58 core.c
@@ -0,0 +1,58 @@
+// This contains the giant switch core that will run the lorito microcode.
+
+#include "lorito.h"
+#include "microcode.h"
+
+void
+core_exec(Lorito_Interp interp)
+{
+ int *pc;
+
+ while (pc)
+ {
+ switch (*pc)
+ {
+ case OP_end:
+ break;
+ case OP_add:
+ break;
+ case OP_sub:
+ break;
+ case OP_mul:
+ break;
+ case OP_div:
+ break;
+ case OP_set:
+ break;
+ case OP_goto:
+ break;
+ case OP_if:
+ break;
+ case OP_iseq:
+ break;
+ case OP_isgt:
+ break;
+ case OP_islt:
+ break;
+ case OP_and:
+ break;
+ case OP_or:
+ break;
+ case OP_new:
+ break;
+ case OP_call:
+ break;
+ case OP_load:
+ break;
+ case OP_read:
+ break;
+ case OP_write:
+ break;
+ case OP_gripe:
+ break;
+ default:
+ // Error
+ break;
+ }
+ }
+}
@@ -0,0 +1,3 @@
+// This will load a lorito bytecode file into a lorito codeseg
+
+
@@ -0,0 +1,58 @@
+// This contains all the structures for lorito
+
+#ifndef LORITO_LORITO_H_GUARD
+#define LORITO_LORITO_H_GUARD
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <string.h>
+#include <ctype.h>
+
+struct lorito_interp_t;
+struct lorito_codeseg_t;
+struct lorito_opcode_t;
+struct lorito_ctx_t;
+struct lorito_reg_t;
+
+struct lorito_interp_t
+{
+ struct lorito_ctx_t* ctx;
+ struct lorito_reg_t* regs;
+};
+
+struct lorito_codeseg_t
+{
+ int fileid;
+ int segid;
+ int length;
+ struct lorito_opcode_t* op;
+};
+
+struct lorito_opcode_t
+{
+ unsigned char opcode;
+ unsigned char dest;
+ unsigned char src1;
+ unsigned char src2;
+};
+
+struct lorito_reg_t
+{
+ int regs_i[REGNUM];
+};
+
+struct lorito_ctx_t
+{
+ struct lorito_ctx_t* next_ctx;
+ int pc;
+ struct lorito_codeseg_t* current_codeseg;
+ struct lorito_reg_t regs;
+};
+
+typedef struct lorito_interp_t Lorito_Interp;
+
+#endif /* LORITO_LORITO_H_GUARD */
6 main.c
@@ -0,0 +1,6 @@
+// This is the actual main program
+
+int
+main(int argc, const char *argv[])
+{
+}
@@ -0,0 +1,32 @@
+// This contains the definitions of the microcode format
+
+#ifndef LORITO_MICROCODE_H_GUARD
+#define LORITO_MICROCODE_H_GUARD
+
+
+enum OPS_ENUM {
+ OP_noop = 0,
+ OP_end = 1,
+ OP_add = 2,
+ OP_sub = 3,
+ OP_mul = 4,
+ OP_div = 5,
+ OP_set = 6,
+ OP_goto = 7,
+ OP_if = 8,
+ OP_iseq = 9,
+ OP_isgt = 10,
+ OP_islt = 11,
+ OP_and = 12,
+ OP_or = 13,
+ OP_new = 14,
+ OP_call = 15,
+ OP_load = 16,
+ OP_read = 17,
+ OP_write = 18,
+ OP_gripe = 19,
+
+ OP_hcf = 255
+};
+
+#endif /* LORITO_MICROCODE_H_GUARD */

0 comments on commit e486e74

Please sign in to comment.