A project to implement a console using the Mbed using VGA for video output and a PS/2 keyboard for the input. The eventual goal is to also include tools for managing SD cards, and a semi-self-hosting programming environment.

Dependencies:   PS2_MbedConsole fastlib SDFileSystem vga640x480g_mbedconsole lightvm mbed

MbedConsole is a cool little project to have a self-contained computer all on an Mbed. So far it has VGA and PS/2 support and can stand alone without a computer powering it. Next planned features are SD card support and a lightweight programmable VM complete with a file editor and self-hosted assembler.

You can view additional details about it at http://earlz.net/tags/mbedconsole

Revision:
6:a4dff59ef214
Parent:
3:2bc2b0dce10e
Child:
7:2ac6752d47d2
--- a/plEarlz.h	Thu Sep 20 04:43:50 2012 +0000
+++ b/plEarlz.h	Fri Sep 21 04:53:45 2012 +0000
@@ -1,28 +1,99 @@
 #ifndef PLEARLZ_H
 #define PLEARLZ_H
 
+#define MAXSTACK 64
+#define MAXCALLS 32
+#define MAXLINELENGTH 128
+#define DICTIONARYSTEP 4 //how much memory to reserve when doing a reallocation for resizing
+#define CODEBLOCKSTEP 16
+
+enum ErrorType
+{
+    None,
+    StackOverflow,
+    StackUnderflow
+};
+
+//arguments are in the bytecode, not the stack! But, things like Add has no arguments and uses the stack
+//pointers are assumed 32-bit?
+enum Opcode
+{
+    BranchTrue, //argument is 16 bit vaddress
+    BranchFalse, //argument is 16bit vaddress
+    Branch,
+    Push, //argument is 32bit number
+    Pop, //trashes top value on stack
+    Call, //call. argument is WORD entry pointer in dictionary
+    CallInt, //call internal argument is function pointer
+    Add,
+    Sub,
+    Mul,
+    Div,
+    Mod,
+    Cgt, //takes two integers and compares for greater than pushes 1 if so, 0 if not
+    Clt, //less than
+    Cgte, //greater than or equal
+    Clte,
+    Ceq,
+    Cneq,
+    LoadStr, //argument is variable length string ending with 0. Pushes address onto stack
+    Load, //pushes the value pointed to by the argument
+    Store, //pops a value and stores it in the memory pointed to by the argument
+    New, //pushes a pointer to free memory for an integer
+    NewVar, //pushes a pointer to memory. Size is specified by argument
+    Delete, //pops a pointer and frees it. 
+    Ret //exit
+};
+
+typedef void (*BuiltinFunction)(void);
+typedef struct
+{
+    char name[12];
+    enum Type{
+        Constant,
+        ConstantString,
+        Builtin,
+        Function
+    } type;
+    union valueunion{
+        int intvalue;
+        BuiltinFunction builtin;
+        char *string;
+    } value;
+} WordKey;
+
+extern ErrorType pl_error;
 
 int pl_shell();
 
 static inline int is_whitespace(char c){
-	return (c==' ') || (c=='\t') || (c=='\n') || (c=='\r');
+    return (c==' ') || (c=='\t') || (c=='\n') || (c=='\r');
 }
 
 static inline int is_numeric(char c){
-	return (c>='0') && (c<='9');
+    return (c>='0') && (c<='9');
 }
 
 static inline int is_alpha(char c){
-	return ((c>='a') && (c<='z')) || ((c>='A') && (c<='Z'));
+    return ((c>='a') && (c<='z')) || ((c>='A') && (c<='Z'));
 }
 
 static inline int is_identifier(char c){
-	return is_alpha(c) || is_numeric(c) || (c=='_');
+    return is_alpha(c) || is_numeric(c) || (c=='_');
 }
 
 static inline int is_quote(char c){
-	return (c=='\"') || (c=='\'');
+    return (c=='\"') || (c=='\'');
 }
+int forth_execute(uint8_t* block, int length);
+WordKey *pl_lookup(char* name);
+int pl_pop();
+void pl_push(int val);
+
+
+
+//builtin functions
+void bi_print();
 
 
 #endif
\ No newline at end of file