pforth  0943e5e71114f286dbb2474d55aabf91df02d104
pforth.c File Reference
#include <string.h>
#include "pforth.h"

Functions

uint8_t * data_stack_bottom ()
 
uint8_t * return_stack_bottom ()
 
pforth_word_ptr pforth_word_alloc ()
 
void pforth_word_free (const pforth_word_ptr word)
 
void pforth_init ()
 
void pforth_deinit ()
 
pforth_word_ptr pforth_word_copy (const pforth_word_ptr dest, const pforth_word_ptr src)
 
void dump_stack ()
 
void register_native (const char *op, word_function f)
 

Variables

uint8_t * data_stack_top
 
void * return_stack_top
 
dict_tforth_dict
 
static uint8_t * _data_stack_bottom
 
static uint8_t * _return_stack_bottom
 

Function Documentation

uint8_t* data_stack_bottom ( )
void dump_stack ( )

Debug printer for the whole data stack

void pforth_deinit ( )

Free the FORTH machine internal structures.

Deallocate stacks, remove dictionary.

void pforth_init ( )

Init the FORTH machine.

Allocate stacks, create dictionary.

pforth_word_ptr pforth_word_alloc ( )

Allocate memory for new word

Returns
pointer to new word
NULL if not enough memory
pforth_word_ptr pforth_word_copy ( const pforth_word_ptr  dest,
const pforth_word_ptr  src 
)

Copy the word from src to dest

The dest must be allocated beforehand.

Parameters
srcsource word
destdestination buffer
Returns
pointer to the buffer (equal to dest)
NULL if not enough memory
void pforth_word_free ( const pforth_word_ptr  word)

Free the word structure

Parameters
wordthe word to free
void register_native ( const char *  op,
word_function  f 
)

Register native (compile-time) word

Parameters
opThe FORTH word to add
fFunction to call
uint8_t* return_stack_bottom ( )

Variable Documentation

uint8_t* _data_stack_bottom
static

The global data stack bottom

uint8_t* _return_stack_bottom
static

The global return stack bottom

uint8_t* data_stack_top

The global data stack top pointer for the FORTH machine

dict_t* forth_dict

Storage for the FORTH words

void* return_stack_top