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

VirtualRAM.h

Committer:
va009039
Date:
2015-05-13
Revision:
1:e74530ad6b9e

File content as of revision 1:e74530ad6b9e:

// VirtualRAM.h 2015/4/29
#pragma once
#define PAGE_CHUNK_SIZE 1024
class VirtualRAM {
public:
    int used_size;
	VirtualRAM(): used_size(0) {
        memset(mem_ptr, 0x00, sizeof(mem_ptr)); // NULL
    }
    uint8_t peek(uint16_t a) {
        uint8_t* mem = ptr(a);
        if (mem == NULL) {
            return 0x00;
        }
        return mem[a % PAGE_CHUNK_SIZE];
    }
    void poke(uint16_t a, uint8_t b) {
        uint8_t* mem = ptr(a);
        if (mem == NULL) {
            mem = reinterpret_cast<uint8_t*>(malloc(PAGE_CHUNK_SIZE));
            MBED_ASSERT(mem != NULL);
            mem_ptr[idx(a)] = mem;
            used_size += PAGE_CHUNK_SIZE;
        }
    	mem[a % PAGE_CHUNK_SIZE] = b;
    }

private:
    uint8_t* ptr(uint16_t addr) {
        return mem_ptr[idx(addr)];
    }
    int idx(uint16_t addr) {
        return addr / PAGE_CHUNK_SIZE;
    }
    uint8_t* mem_ptr[65536 / PAGE_CHUNK_SIZE];
};