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:
9:4211d638b2e9
Parent:
8:f356684767ef
Child:
13:442bd2fb4ea0
--- a/forth_machine.cpp	Sat Sep 22 04:14:01 2012 +0000
+++ b/forth_machine.cpp	Wed Sep 26 04:12:57 2012 +0000
@@ -76,7 +76,27 @@
     return pl_dictionary_count++;
 }
 
-
+int pl_tempstack[MAXTEMPSTACK];
+int pl_temppos=0;
+void pl_temppush(int val)
+{
+    if(pl_temppos>=MAXTEMPSTACK)
+    {
+        vputs("Temporary stack overflow\n");
+        return;
+    }
+    pl_tempstack[pl_temppos]=val;
+    pl_temppos++;
+}
+int pl_temppop()
+{
+    if(pl_temppos<=0)
+    {
+        vputs("Temporary stack underflow\n");
+        return 0;
+    }
+    return pl_tempstack[pl_temppos--];
+}
 
 int forth_execute(uint8_t* block, int length)
 {
@@ -118,7 +138,7 @@
                 pl_push(*(uint32_t*)&block[pos]);
                 pos+=4;
                 break;
-            case Pop:
+            case Drop:
                 pos++;
                 pl_pop();
                 break;
@@ -166,12 +186,38 @@
                 pos++;
                 pl_push(pl_pop()!=pl_pop());
                 break;
-            case CallInt:
+            case CallInt:{
                 pos++;
                 uint32_t tmp=*(uint32_t*)&block[pos];
                 ((BuiltinFunction)tmp)();
                 pos+=4;
+                break;}
+            case Swap:{
+                pos++;
+                int tmp=pl_pop();
+                int tmp2=pl_pop();
+                pl_push(tmp);
+                pl_push(tmp2);
                 break;
+                }
+            case PushTemp:
+                pos++;
+                pl_temppush(pl_pop());
+                break;
+            case PopTemp:
+                pos++;
+                pl_push(pl_temppop());
+            case Pick:{
+                pos++;
+                int tmp=pl_pop();
+                if(pl_stackpos-tmp>0){
+                    pl_push(pl_stack[pl_stackpos-tmp]);
+                    
+                }else{
+                    pl_push(0);
+                    vputs("Stack underflow on pick\n");
+                }
+                break;}
             case Ret:
                 return 0;