eForth1  v2.4
eforth1.cpp File Reference
#include "eforth_core.h"
#include "eForth1.h"
#include <EEPROM.h>
Include dependency graph for eforth1.cpp:

Macros

#define GET(d)   (*(DU*)&ram[d])
 
#define SET(d, v)   (*(DU*)&ram[d] = (v))
 

Functions

void _stat (U8 *ram, int sz, Stream *io)
 
int ef_save (U8 *ram)
 save user variables and dictionary to EEPROM More...
 
int ef_load (U8 *ram)
 load user variables and dictionary from EEPROM More...
 
void ef_setup (const char *code, Stream &io_stream)
 
void ef_run ()
 
char * ef_ram (int i)
 expose VM RAM space to Sketch More...
 

Variables

U32 forth_rom []
 
U32 forth_rom_sz
 
static U8 forth_ram [FORTH_RAM_SZ]
 RAM pointer (malloc) More...
 
static Stream * io
 

Macro Definition Documentation

◆ GET

#define GET (   d)    (*(DU*)&ram[d])

EEPROM interface

EEPROM Save/Load

◆ SET

#define SET (   d,
 
)    (*(DU*)&ram[d] = (v))

Function Documentation

◆ _stat()

void _stat ( U8 ram,
int  sz,
Stream *  io 
)

display eForth system information

< freelist

< start of heap

< end of heap

◆ ef_save()

int ef_save ( U8 ram)

save user variables and dictionary to EEPROM

  • store dictionary byte-by-byte

◆ ef_load()

int ef_load ( U8 ram)

load user variables and dictionary from EEPROM

< CP addr in EEPROM (aka HERE)

  • >IN (buffer pointer)
  • keep vIN, vNTIB
  • retrieve dictionary byte-by-byte
  • restore vIN, vNTIB

◆ ef_setup()

void ef_setup ( const char *  code,
Stream &  io_stream 
)

setup (called by Arduino setup)

◆ ef_run()

void ef_run ( )

VM outer interpreter proxy

◆ ef_ram()

char* ef_ram ( int  i)

expose VM RAM space to Sketch

VM RAM space

Variable Documentation

◆ forth_rom

const U32 forth_rom

Forth ROM image (eforth_rom.c, generated by eforth_asm.c)

◆ forth_rom_sz

U32 forth_rom_sz

actual size of ROM

◆ forth_ram

U8 forth_ram[FORTH_RAM_SZ]
static

RAM pointer (malloc)

Forth managed memory block

Note
: dynamic allocation is usually a bad idea for MCU 1) uses 4 more bytes of RAM (freelist), 2) uses ~700 bytes of Flash (allocator), 3) does prevent IDE complaints about low memory in compile time

◆ io

Stream* io
static

IO stream (Serial Monito///