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
Diff: plEarlz.cpp
- Revision:
- 3:2bc2b0dce10e
- Child:
- 4:b44c27404035
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plEarlz.cpp Wed Sep 19 04:44:07 2012 +0000 @@ -0,0 +1,107 @@ +#include "mbedconsole.h" +#include "plEarlz.h" +#include <stdarg.h> +//Basically a non-conforming take on Forth, btw. + +inline int internal_captureline(void* pBuffer, char const* pFormatString, ...) +{ + char* pStringEnd = (char*)pBuffer + strlen((char*)pBuffer); + va_list valist; + + va_start(valist, pFormatString); + + return vsprintf(pStringEnd, pFormatString, valist); +} +void printheapstats() +{ + char buffer[256]; + __heapstats(internal_captureline, buffer); + vputs("Memory info: "); + vputs(buffer); +} + +struct pl_word +{ + +}; + +#define MAXSTACK 256 +#define MAXCALLS 64 +#define MAXLINELENGTH 128 + +int stackpos=0; +int pl_stack[MAXSTACK]; + +//int *pl_callstack[MAXCALLS]; + +enum WordType +{ + Unknown, + Number, + Word, + Quote +}; + +void execute_word(char *word) +{ + + +} + +void parse_line(char *line) +{ + int len=strlen(line); + char word[16]; + word[0]=0; + int wordpos=0; + WordType type=Unknown; + for(int i=0;i<len;i++) + { + char c=line[i]; + if(is_whitespace(c)) + { + if(word[0]!=0) + { + execute_word(word); + word[0]=0; + type=Unknown; + } + }else if(is_numeric(c)){ + type=Number; + word[wordpos]=c; + wordpos++; + }else if(is_quote(c)){ + vputs("This isn't supported yet foo!"); + }else{ + type=Word; + word[wordpos]=c; + wordpos++; + } + } +} + + + +int pl_shell() +{ + vputs(">>plEarlz -- A forth-ish shell<<\n"); + printheapstats(); + vputs("\n"); + char *line=(char*)malloc(MAXLINELENGTH); + sprintf(line, "Stack Size: %i; Max Recursion Level %i; Loaded WORDs: %i", MAXSTACK, MAXCALLS, 0); + vputs(line); + sprintf(line, "Max line length: %i", MAXLINELENGTH); + vputs(line); + char *tmp=(char*)malloc(32); //for constructing words/elements + while(1) + { + vputs("cmd> "); + vgetsl(line, MAXLINELENGTH); + line[MAXLINELENGTH-1]=0; + parse_line(line); + + } + return 0; +} + +