eForth1  v2.4
eforth_vm.cpp File Reference

eForth Virtual Machine module More...

#include "eforth_vm.h"
Include dependency graph for eforth_vm.cpp:

Namespaces

 EfVM
 

Macros

#define OP(name)   op##name
 
#define _X(n, code)   case op##n: { DEBUG("%s",#n); { code; } break; }
 
#define DISPATCH(op)   switch(op)
 

Functions

void EfVM::_init ()
 
void EfVM::_yield ()
 

yield to interrupt service

More...
 
void EfVM::_qrx ()
 

( – c ) fetch a char from console

More...
 
void EfVM::_txsto ()
 

(c – ) send a char to console

More...
 
void EfVM::_ummod ()
 (udl udh u – ur uq) unsigned double divided by a single More...
 
void EfVM::_out (U16 p, U16 v)
 
void vm_init (PGM_P rom, U8 *ram, void *io_stream, const char *code)
 
void _ccall ()
 
void vm_cfunc (int n, CFP fp)
 

function pointer

More...
 
void vm_push (int v)
 push value onto VM data stack More...
 
int vm_pop ()
 pop TOS off VM data stack More...
 

Variables

VM Registers
IU EfVM::IP
 instruction pointer, IU is 16-bit, opcode is 8-bit More...
 
IU EfVM::W
 work register, IU is 16-bit More...
 
DUEfVM::DS
 data stack pointer, Dr. Ting's stack More...
 
DUEfVM::RS
 return stack pointer, Dr. Ting's rack More...
 
DU EfVM::top
 ALU (i.e. cached top of stack value) More...
 
DU EfVM::rtop
 cached loop counter on return stack More...
 
IU EfVM::IR
 interrupt service routine More...
 
Memory Management Unit
PGM_P EfVM::_rom
 ROM, Forth word stored in Arduino Flash Memory. More...
 
U8EfVM::_ram
 RAM, memory block for user define dictionary. More...
 
U8EfVM::_pre
 Pre-built/embedded Forth code. More...
 
CFP EfVM::_api [CFUNC_MAX]
 
IO Streaming interface
Stream * EfVM::io
 Stream IO interface. More...
 
VM Registers
IU EfVM::IP
 instruction pointer, IU is 16-bit, opcode is 8-bit More...
 
IU EfVM::W
 work register, IU is 16-bit More...
 
DUEfVM::DS
 data stack pointer, Dr. Ting's stack More...
 
DUEfVM::RS
 return stack pointer, Dr. Ting's rack More...
 
DU EfVM::top
 ALU (i.e. cached top of stack value) More...
 
DU EfVM::rtop
 cached loop counter on return stack More...
 
IU EfVM::IR
 interrupt service routine More...
 
Memory Management Unit
PGM_P EfVM::_rom
 ROM, Forth word stored in Arduino Flash Memory. More...
 
U8EfVM::_ram
 RAM, memory block for user define dictionary. More...
 
U8EfVM::_pre
 Pre-built/embedded Forth code. More...
 
CFP EfVM::_api [CFUNC_MAX]
 
IO Streaming interface
Stream * EfVM::io
 Stream IO interface. More...
 

Detailed Description

eForth Virtual Machine module

Revision Note: Threading model evolution 202212 EfVMSub module - vtable subroutine calling 202301 indirect threading - computed label jumping 202302 direct threading - opcode => code(); continue = $NEXT

Macro Definition Documentation

◆ OP

#define OP (   name)    op##name

◆ _X

#define _X (   n,
  code 
)    case op##n: { DEBUG("%s",#n); { code; } break; }

◆ DISPATCH

#define DISPATCH (   op)    switch(op)

Function Documentation

◆ vm_init()

void vm_init ( PGM_P  rom,
U8 ram,
void *  io_stream,
const char *  code 
)
  • resetting user variables

◆ _ccall()

void _ccall ( )

C interface implementation

TODO: build formal C callstack construct

fetch C function pointer

pop off TOS

call C function

◆ vm_cfunc()

void vm_cfunc ( int  n,
CFP  fp 
)

function pointer

assign C interface (in slot n)

◆ vm_push()

void vm_push ( int  v)

push value onto VM data stack

proxy to VM

◆ vm_pop()

int vm_pop ( )

pop TOS off VM data stack