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:
8:f356684767ef
Parent:
7:2ac6752d47d2
Child:
9:4211d638b2e9
--- a/plEarlz.cpp	Sat Sep 22 03:00:55 2012 +0000
+++ b/plEarlz.cpp	Sat Sep 22 04:14:01 2012 +0000
@@ -25,7 +25,7 @@
 
 
 
-volatile BranchTarget *last_target=NULL;   
+BranchTarget *last_target=NULL;   
 
 ErrorType pl_error=None;
 
@@ -127,9 +127,9 @@
 }
  
 
-void push_target(uint16_t* address)
+void push_target(int address)
 {
-    volatile BranchTarget* target=(BranchTarget*)malloc(sizeof(BranchTarget));
+    BranchTarget* target=(BranchTarget*)malloc(sizeof(BranchTarget));
     target->previous=last_target;
     target->target=address;
     last_target=target;
@@ -145,6 +145,10 @@
     last_target=last_target->previous;
     free((void*)tmp);
 }
+inline void write_blockword(int pos,uint16_t val)
+{
+    *(uint16_t*)&pl_codeblock[pos]=val;
+}
 
 int compile_word(char *word, WordType type) //returns 0 for success, 1 for ending word found, -1 for error
 {
@@ -187,19 +191,18 @@
             }
         
         }else if(strlcmp("if", word, 3)==0){
-            printf("if statement %x\r\n", pl_blockpos);
             push_opcode(BranchFalse);
-            push_target(push_opcode_word(0));
+            push_target(pl_blockpos);
+            push_opcode_word(0);
         }else if(strlcmp("else", word, 5)==0){
-            printf("else statement %x\r\n", pl_blockpos);
             push_opcode(Branch);
-            uint16_t* tmp=push_opcode_word(0); 
-            volatile uint16_t* tmp2=last_target->target;
-            *tmp2=pl_blockpos;
+            int tmp=pl_blockpos;
+            push_opcode_word(0); 
+            write_blockword(last_target->target,pl_blockpos);
             pop_target(); 
             push_target(tmp); //have to do it after we pop it or we fall into an infinite loop!
         }else if(strlcmp("end", word, 4)==0){
-            *(last_target->target)=pl_blockpos;
+            write_blockword(last_target->target,(uint16_t)pl_blockpos);
             pop_target();
         }else{
             vputs("I don't know the word '");
@@ -270,15 +273,6 @@
 
 int pl_shell()
 {
-    uint8_t* tmpf[20];
-    push_target((uint16_t*)&tmpf[2]);
-    *last_target->target=50;
-    pop_target();
-    push_target((uint16_t*)&tmpf[4]);
-    *last_target->target=200;
-    pop_target();
-    
-    printf("foo: %i %i\r\n", (int)*(uint16_t*)&tmpf[2], (int)*(uint16_t*)&tmpf[4]);
     vputs(">>plEarlz -- A forth-ish shell<<\n");
     printheapstats();
     vputs("\n");