Nuvoton FORTH
 All Classes Files Functions Variables Macros Modules Pages
Macros | Functions | Variables
FORTH.h File Reference

global Virtual Machine headers (ANSI C'89 code shared between byte compiler & embedded) More...

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
Include dependency graph for FORTH.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VM_TRACELOG
 print trace log while program excutes in VM emulator
 
#define Msz   0x10000
 main memory size (bytes)
 
#define Rsz   0x1000
 return stack size (cells)
 
#define Dsz   0x10
 data stack size (cells)
 
#define BYTE   uint8_t
 byte
 
#define CELL   uint32_t
 machine word (cell)
 
#define CELLsz   (sizeof(CELL))
 machine word size in bytes
 
#define op_NOP   0x00
 
#define op_BYE   0xFF
 
#define op_JMP   0x01
 
#define op_qJMP   0x02
 
#define op_CALL   0x03
 
#define op_RET   0x04
 
#define op_QUEST   0xD1
 
#define op_DUMP   0xD1
 

Functions

void save (char *filename)
 save compiled vocabular memory to file More...
 
CELL fetch (CELL addr)
 fetch VM machine word from M address
 
void Bstore (CELL addr, BYTE byte)
 store byte at M address
 
void store (CELL addr, CELL cell)
 store VM machine word at M address
 
void Bcompile (BYTE byte)
 B, ( byte -- ) compile byte
 
void compile (CELL cell)
 , ( cell -- ) compile cell
 
void NOP ()
 NOP ( -- ) no operation
 
void BYE ()
 BYE ( -- ) stop system
 
void JMP ()
 jmp addr ( -- ) unconditional jump
 
void CALL ()
 call addr ( -- ) (R: -- addr) nested call
 
void RET ()
 ret ( -- ) (R: addr -- ) return from nested call
 
void DUMP ()
 dump ( -- ) dump M bytecode until Cp
 
void VM ()
 bytecode interpreter
 

Variables

BYTE M [Msz]
 bytecode memory
 
CELL Ip
 instruction pointer
 
CELL Cp
 compiler pointer
 
CELL R [Rsz]
 return stack for call/ret
 
CELL Rp
 return stack pointer
 

Detailed Description

global Virtual Machine headers (ANSI C'89 code shared between byte compiler & embedded)

Function Documentation

void save ( char *  filename)

save compiled vocabular memory to file

Parameters
[in]filenamefilename (ignored in embedded without file system support)