Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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: forth_machine.cpp
- Revision:
- 8:f356684767ef
- Parent:
- 7:2ac6752d47d2
- Child:
- 9:4211d638b2e9
--- a/forth_machine.cpp Sat Sep 22 03:00:55 2012 +0000
+++ b/forth_machine.cpp Sat Sep 22 04:14:01 2012 +0000
@@ -81,11 +81,12 @@
int forth_execute(uint8_t* block, int length)
{
uint16_t pos=0;
+ printf("block length: %x\r\n",length);
while(pos<length)
{
- serial.getc();
+ //serial.getc();
Opcode op=(Opcode)block[pos];
- printf("opcode: %x\r\n",(int)op);
+ printf("pos: %x -- opcode: %x\r\n",(int)pos, (int)op);
switch(op)
{
case BranchTrue:
@@ -100,6 +101,7 @@
case BranchFalse:
if(!pl_pop()){
pos++;
+ serial.printf("branch false %x\r\n",(int)pos);
pos=*((uint16_t*)&block[pos]);
serial.printf("branch false %x\r\n",(int)pos);
}else{
@@ -140,6 +142,30 @@
pos++;
pl_push(pl_pop()%pl_pop());
break;
+ case Cgt:
+ pos++;
+ pl_push(pl_pop()>pl_pop());
+ break;
+ case Clt:
+ pos++;
+ pl_push(pl_pop()<pl_pop());
+ break;
+ case Cgte:
+ pos++;
+ pl_push(pl_pop()>=pl_pop());
+ break;
+ case Clte:
+ pos++;
+ pl_push(pl_pop()<=pl_pop());
+ break;
+ case Ceq:
+ pos++;
+ pl_push(pl_pop()==pl_pop());
+ break;
+ case Cneq:
+ pos++;
+ pl_push(pl_pop()!=pl_pop());
+ break;
case CallInt:
pos++;
uint32_t tmp=*(uint32_t*)&block[pos];
@@ -147,7 +173,7 @@
pos+=4;
break;
case Ret:
- return;
+ return 0;
default: