IPS(Interpreter for Process Structures) for mbed
Dependencies: ConfigFile FATFileSystem mbed
IPS port from linux/unix version.
mbed_blinky.ips
0 VAR led1 " LED1 " DigitalOut led1 ! : main ANFANG 1 JA? 1 led1 @ write 200 wait_ms 0 led1 @ write 200 wait_ms DANN/NOCHMAL ; main
- ips-02.tgz - ips for linux/unix
- ipsdoc.zip - document
- https://bitbucket.org/va009039/ips/
Diff: BaseIPS.cpp
- Revision:
- 2:908338b1151a
- Parent:
- 1:e74530ad6b9e
--- a/BaseIPS.cpp Wed May 13 18:39:01 2015 +0900 +++ b/BaseIPS.cpp Sat May 23 16:50:59 2015 +0900 @@ -1,9 +1,12 @@ -// BaseIPS.cpp 2015/5/6 +// BaseIPS.cpp 2015/5/22 +#include <algorithm> #include "mbed.h" #include "BaseIPS.h" +#ifndef NO_MATH #include <math.h> #define Round(x) ( (x>=0) ? (int)(x+0.5) : (int)(x-0.5) ) +#endif BaseIPS::BaseIPS() { PS = 0xfff8; @@ -58,7 +61,7 @@ depth++; } -void BaseIPS::c_consex(void) { // 2 +void BaseIPS::c_consex(void) { // 2 push_ps(peek(HP)); } @@ -402,11 +405,11 @@ void BaseIPS::c_cyc2(void) { // 50 u32 ch,a,crcc; int i; - + ch=pull_ps(); a=pull_ps(); crcc=(a>>8)|((a&0xff)<<8); - + ch<<=8; for (i=0;i<=7;i++) { //int test; @@ -430,13 +433,11 @@ if (inputfile) { file_close(inputfile); } - int namelen = pull_ps(); + size_t namelen = pull_ps(); int namestart = pull_ps(); char filename[256]; - if (namelen > sizeof(filename)-1) { - namelen = sizeof(filename) - 1; - } - for(int i = 0; i < namelen; i++) { + namelen = std::min(namelen, sizeof(filename)-1); + for(size_t i = 0; i < namelen; i++) { filename[i] = peekB(namestart + i); } filename[namelen] = '\0'; @@ -489,6 +490,7 @@ PS=pull_ps(); } +#ifndef NO_MATH void BaseIPS::c_rp_code(void) { // 59 double theta,x,y,r; pull_ps(); @@ -514,6 +516,14 @@ push_ps(Round(r*cos(theta))); push_ps(Round(r*sin(theta))); } +#else +void BaseIPS::c_rp_code(void) { + error("c_rp_code not implemented!\n"); +} +void BaseIPS::c_tr_code(void) { + error("c_tr_code not implemented!\n"); +} +#endif void BaseIPS::c_swap3(void) { // 61 u16 h; @@ -546,15 +556,6 @@ push_ps(c>>16); } -void BaseIPS::c_sleepifidle(void) { // 80 -/* extension for IPS-Mu, i.e., the linux/unix version */ - if (idle) { - //do_sleep(); - //leaveloop=0; - } - idle=1; -} - void BaseIPS::do_20ms(void) { pokeB(UHR, peekB(UHR) + 2); // 20ms if (peekB(UHR) == 100) { @@ -609,14 +610,14 @@ do { int ch = file_getc(inputfile); - if (ch<1) { + if (ch<1) { if (input_ptr == peek(a_PI)) { - file_close(inputfile); - inputfile = NULL; - pokeB(LOADFLAG, 0); + file_close(inputfile); + inputfile = NULL; + pokeB(LOADFLAG, 0); input_ptr = 0x200; } - break; + break; } if (ch=='\r') { /* ignore \r, we expect at least also a \n as end-of-line */ @@ -644,6 +645,7 @@ HP += 2; trace(cycle++, PPC-2, HP-2, CPC, PS, RS); switch(CPC) { + case 0: c_rumpelstilzchen(); break; case 1: c_defex(); break; case 2: c_consex(); break; case 3: c_varex(); break; @@ -708,8 +710,7 @@ case 62: c_defchar(); break; case 63: c_pplus(); break; case 64: c_pminus(); break; - case 80: c_sleepifidle(); break; - default: c_rumpelstilzchen(); break; + default: usercode(CPC); break; } do_io(); if (test_20ms()) {