eForth1  v2.4
eforth_asm.h File Reference

eForth assembler module header More...

#include "eforth_config.h"
Include dependency graph for eforth_asm.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ASM_TRACE   0 /** create assembler trace */
 
#define CASE_SENSITIVE   0 /** enable case sensitive */
 
#define ENABLE_SEE   1 /** add SEE, +280 bytes */
 
#define fCMPL   0x40
 
#define fIMMD   0x80
 
#define OP(name)   op##name
 
#define DEBUG(s, v)
 
#define SHOWOP(op)
 
#define _ARG_N( _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, N, ...)   N
 
#define _NUM_N()
 
#define _NARG0(...)   _ARG_N(__VA_ARGS__)
 
#define _NARG(...)   _NARG0(_, ##__VA_ARGS__, _NUM_N())
 
#define CELLCPY(n)
 
#define MEMCPY(len, seq)
 
#define OPSTR(ip, seq)
 
Vargs Header (calculate number of parameters by compiler)
#define _CODE(seg, ...)   _code(seg, _NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _PRIM(seg, x)   (_CODE(seg, op##x, opEXIT), op##x)
 
#define _COLON(seg, ...)   _colon(seg, _NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _IMMED(seg, ...)   _immed(seg, _NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _LABEL(...)   _label(_NARG(__VA_ARGS__), __VA_ARGS__)
 
Vargs Branching
#define _BEGIN(...)   _begin(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _AGAIN(...)   _again(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _UNTIL(...)   _until(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _WHILE(...)   _while(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _REPEAT(...)   _repeat(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _IF(...)   _if(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _ELSE(...)   _else(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _THEN(...)   _then(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _FOR(...)   _for(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _NEXT(...)   _nxt(_NARG(__VA_ARGS__), __VA_ARGS__)
 
#define _AFT(...)   _aft(_NARG(__VA_ARGS__), __VA_ARGS__)
 
Vargs IO
#define _DOTQ(str)   _dotq(str)
 
Memory Access and Stack Op
#define BSET(d, c)   (_byte[d]=(U8)(c))
 
#define BGET(d)   (_byte[d])
 
#define SET(d, v)   do { U16 a=(d); U16 x=(v); BSET(a,(x)>>8); BSET((a)+1,(x)&0xff); } while (0)
 
#define GET(d)   ({ U16 a=(d); ((U16)BGET(a)<<8) | BGET((a)+1); })
 
#define STORE(v)   do { SET(PC,(v)); PC+=CELLSZ; } while(0)
 
#define RPUSH(a)   SET(FORTH_ROM_SZ - (++R)*CELLSZ, (a)) /** tail section of memory block */
 
#define RPOP()   ((U16)GET(FORTH_ROM_SZ - (R ? R-- : R)*CELLSZ))
 
#define VL(a, i)   (((U16)(a)+CELLSZ*(i))&0xff)
 
#define VH(a, i)   (((U16)(a)+CELLSZ*(i))>>8)
 
#define VAL(a, i)   opDOLIT,VH(a,i),VL(a,i),opEXIT
 

Enumerations

enum  { opNOP = 0, OPCODES }
 

Functions

void _dump (int b, int u)
 
void _rdump ()
 

dump return stack

More...
 
void _header (int lex, const char *seq)
 
int _code (const char *seg, int len,...)
 
int _colon (const char *seg, int len,...)
 
int _immed (const char *seg, int len,...)
 
int _label (int len,...)
 
void _begin (int len,...)
 
void _while (int len,...)
 
void _repeat (int len,...)
 
void _until (int len,...)
 
void _again (int len,...)
 
void _for (int len,...)
 
void _aft (int len,...)
 
void _nxt (int len,...)
 

Note: _next() is multi-defined in vm

More...
 
void _if (int len,...)
 
void _else (int len,...)
 
void _then (int len,...)
 
void _dotq (const char *seq)
 

Variables

IU PC
 assembler program counter More...
 
U8 R
 assembler return stack index More...
 
IU _link
 link to previous word More...
 
U8_byte
 assembler byte array (heap) More...
 
IU DOTQP
 addr of output ops, used by _dotq, _strq, _abortq More...
 

Detailed Description

eForth assembler module header

Usage of VA_ARGS variable argument for assembler parameter counting

Macro Definition Documentation

◆ ASM_TRACE

#define ASM_TRACE   0 /** create assembler trace */

◆ CASE_SENSITIVE

#define CASE_SENSITIVE   0 /** enable case sensitive */

◆ ENABLE_SEE

#define ENABLE_SEE   1 /** add SEE, +280 bytes */

◆ fCMPL

#define fCMPL   0x40

Name field +-------—+----------—+ | len byte | name string | +-------—+----------—+ Forth name len max 31 the following flags are used to flag word attributes compile only flag

◆ fIMMD

#define fIMMD   0x80

immediate flag

◆ OP

#define OP (   name)    op##name

define opcode enums Note: in sync with VM's vtable

◆ DEBUG

#define DEBUG (   s,
 
)

◆ SHOWOP

#define SHOWOP (   op)

◆ _ARG_N

#define _ARG_N (   _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  _11,
  _12,
  _13,
  _14,
  _15,
  _16,
  _17,
  _18,
  _19,
  _20,
  _21,
  _22,
  _23,
  _24,
  _25,
  _26,
  _27,
  _28,
  _29,
  _30,
  _31,
  _32,
  _33,
  _34,
  _35,
  _36,
  _37,
  _38,
  _39,
  _40,
  _41,
  _42,
  _43,
  _44,
  _45,
  _46,
  _47,
  _48,
  _49,
  _50,
  _51,
  _52,
  _53,
  _54,
  _55,
  _56,
  _57,
  _58,
  _59,
  _60,
  _61,
  _62,
  _63,
  N,
  ... 
)    N

variable length parameter handler macros

◆ _NUM_N

#define _NUM_N ( )
Value:
62, 61, 60, \
59, 58, 57, 56, 55, 54, 53, 52, 51, 50, \
49, 48, 47, 46, 45, 44, 43, 42, 41, 40, \
39, 38, 37, 36, 35, 34, 33, 32, 31, 30, \
29, 28, 27, 26, 25, 24, 23, 22, 21, 20, \
19, 18, 17, 16, 15, 14, 13, 12, 11, 10, \
9, 8, 7, 6, 5, 4, 3, 2, 1, 0

◆ _NARG0

#define _NARG0 (   ...)    _ARG_N(__VA_ARGS__)

◆ _NARG

#define _NARG (   ...)    _NARG0(_, ##__VA_ARGS__, _NUM_N())

◆ _CODE

#define _CODE (   seg,
  ... 
)    _code(seg, _NARG(__VA_ARGS__), __VA_ARGS__)

◆ _PRIM

#define _PRIM (   seg,
 
)    (_CODE(seg, op##x, opEXIT), op##x)

◆ _COLON

#define _COLON (   seg,
  ... 
)    _colon(seg, _NARG(__VA_ARGS__), __VA_ARGS__)

◆ _IMMED

#define _IMMED (   seg,
  ... 
)    _immed(seg, _NARG(__VA_ARGS__), __VA_ARGS__)

◆ _LABEL

#define _LABEL (   ...)    _label(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _BEGIN

#define _BEGIN (   ...)    _begin(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _AGAIN

#define _AGAIN (   ...)    _again(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _UNTIL

#define _UNTIL (   ...)    _until(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _WHILE

#define _WHILE (   ...)    _while(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _REPEAT

#define _REPEAT (   ...)    _repeat(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _IF

#define _IF (   ...)    _if(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _ELSE

#define _ELSE (   ...)    _else(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _THEN

#define _THEN (   ...)    _then(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _FOR

#define _FOR (   ...)    _for(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _NEXT

#define _NEXT (   ...)    _nxt(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _AFT

#define _AFT (   ...)    _aft(_NARG(__VA_ARGS__), __VA_ARGS__)

◆ _DOTQ

#define _DOTQ (   str)    _dotq(str)

◆ BSET

#define BSET (   d,
 
)    (_byte[d]=(U8)(c))

◆ BGET

#define BGET (   d)    (_byte[d])

◆ SET

#define SET (   d,
 
)    do { U16 a=(d); U16 x=(v); BSET(a,(x)>>8); BSET((a)+1,(x)&0xff); } while (0)

◆ GET

#define GET (   d)    ({ U16 a=(d); ((U16)BGET(a)<<8) | BGET((a)+1); })

◆ STORE

#define STORE (   v)    do { SET(PC,(v)); PC+=CELLSZ; } while(0)

◆ RPUSH

#define RPUSH (   a)    SET(FORTH_ROM_SZ - (++R)*CELLSZ, (a)) /** tail section of memory block */

◆ RPOP

#define RPOP ( )    ((U16)GET(FORTH_ROM_SZ - (R ? R-- : R)*CELLSZ))

◆ VL

#define VL (   a,
 
)    (((U16)(a)+CELLSZ*(i))&0xff)

◆ VH

#define VH (   a,
 
)    (((U16)(a)+CELLSZ*(i))>>8)

◆ VAL

#define VAL (   a,
 
)    opDOLIT,VH(a,i),VL(a,i),opEXIT

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
opNOP 

opcodes start at 0

OPCODES