# VM Executable Using Standard Platform
c_cpp.Program('build/bin/slvm', [], LIBS = ['vmkernel', 'stdpf'])
-#nostdlib.Program('build/bin/slvm',
-# glob.glob('source/slvm/*.c'),
-# LIBPATH = ['build/lib'],
-# LIBS = ['gcc', 'stdpf'])
-
-# VM Extensions
-#c_cpp.SharedLibrary('build/lib/ioext', glob.glob('source/slvm/ext/io/*.c'))
+# Build all VM Extensions
+for ext in glob.glob('source/slvm/extensions/*/'):
+ name = os.path.basename(ext.strip('\\/'))
+ c_cpp.StaticLibrary('build/lib/'+name+'ext',
+ glob.glob(ext + '/*.c'),
+ CPPPATH = ['source/slvm/kernel'],
+ LIBS = ['stdpf'])
#include "pal.h"
#include <stdlib.h>
-#if 0
-defcode("if", _if, 1, &bytemove){
+extern word_t zbranch, comma, here, swap, dup, wcode, nrot, rot, sub, wordsz,
+ mul, add, store, branch;
+
+defcode("if", _if, 1, NULL){
/* Compile branch instruction */
ArgStack++;
*(ArgStack) = (val_t)&zbranch;
EXEC(_then);
EXEC(swap);
}
-#endif
dict_t* core_init(dict_t* p_prev)
{
dict_t* p_dict = (dict_t*)pal_allocate(sizeof(dict_t));
p_dict->name = "core";
p_dict->p_prev = p_prev;
- p_dict->p_words = (word_t*)NULL;
- //p_dict->p_words = (word_t*)&_fpeekc;
+ p_dict->p_words = (word_t*)&_else;
return p_dict;
}
#include <string.h>
extern val_t* ArgStack;
+extern val_t* RetStack;
extern val_t* CodePtr;
dict_t* pal_init(dict_t* p_prev_dict);
#define EXEC(word) (word).codeword((word).code)
/** The maximum number of entries that can be on the argument stack */
-#ifndef ARG_STACK_SIZE
-#define ARG_STACK_SIZE 32
+#ifndef STACK_SIZE
+#define STACK_SIZE 32
#endif
/**
#include <stdio.h>
#include <stdlib.h>
-static val_t Stack[ARG_STACK_SIZE];
+static val_t AStack[STACK_SIZE];
+static val_t RStack[STACK_SIZE];
static bool Line_Read = true;
-val_t* ArgStack = Stack - 1;
+
+val_t* ArgStack = AStack - 1;
+val_t* RetStack = RStack - 1;
val_t* CodePtr = 0;
defcode("allocate", mem_alloc, 1, NULL){