Nuvoton FORTH
 All Classes Files Functions Variables Macros Modules Pages
FORTH.h
Go to the documentation of this file.
1 
12 #ifndef _H_FORTH
13 #define _H_FORTH
14 
15 #include <stdint.h>
16 #include <stdlib.h>
17 #include <stdio.h>
18 #include <assert.h>
19 
32 #define VM_TRACELOG
33 
37 #define Msz 0x10000
38 
40 #define Rsz 0x1000
41 
43 #define Dsz 0x10
44 
55 #define BYTE uint8_t
56 
58 #define CELL uint32_t
59 
61 #define CELLsz (sizeof(CELL))
62 
71 extern BYTE M[Msz];
72 
74 extern CELL Ip;
75 
77 extern CELL Cp;
78 
80 extern CELL R[Rsz];
82 extern CELL Rp;
83 
89 extern void save(char* filename);
90 
96 extern CELL fetch(CELL addr);
97 
99 extern void Bstore(CELL addr, BYTE byte);
100 
102 extern void store(CELL addr, CELL cell);
103 
113 extern void Bcompile(BYTE byte);
114 
116 extern void compile(CELL cell);
117 
125 #define op_NOP 0x00
126 #define op_BYE 0xFF
127 
128 #define op_JMP 0x01
129 #define op_qJMP 0x02
130 #define op_CALL 0x03
131 #define op_RET 0x04
132 
133 #define op_QUEST 0xD1
134 #define op_DUMP 0xD1
135 
142 extern void NOP();
143 
145 extern void BYE();
146 
148 extern void JMP();
149 
151 extern void CALL();
152 
154 extern void RET();
155 
157 extern void DUMP();
158 
165 extern void VM();
166 
169 #endif // _H_FORTH
170 
void Bcompile(BYTE byte)
B, ( byte -- ) compile byte
Definition: FORTH.c:18
void JMP()
jmp addr ( -- ) unconditional jump
Definition: FORTH.c:57
CELL fetch(CELL addr)
fetch VM machine word from M address
Definition: FORTH.c:30
void RET()
ret ( -- ) (R: addr -- ) return from nested call
Definition: FORTH.c:74
#define Msz
main memory size (bytes)
Definition: FORTH.h:37
void DUMP()
dump ( -- ) dump M bytecode until Cp
Definition: FORTH.c:81
void BYE()
BYE ( -- ) stop system
Definition: FORTH.c:50
CELL R[Rsz]
return stack for call/ret
Definition: FORTH.c:15
void VM()
bytecode interpreter
Definition: FORTH.c:90
#define CELL
machine word (cell)
Definition: FORTH.h:58
void compile(CELL cell)
, ( cell -- ) compile cell
Definition: FORTH.c:22
BYTE M[Msz]
bytecode memory
Definition: FORTH.c:9
void Bstore(CELL addr, BYTE byte)
store byte at M address
Definition: FORTH.c:26
CELL Cp
compiler pointer
Definition: FORTH.c:13
CELL Ip
instruction pointer
Definition: FORTH.c:11
void CALL()
call addr ( -- ) (R: -- addr) nested call
Definition: FORTH.c:65
void store(CELL addr, CELL cell)
store VM machine word at M address
Definition: FORTH.c:34
#define Rsz
return stack size (cells)
Definition: FORTH.h:40
void NOP()
NOP ( -- ) no operation
Definition: FORTH.c:44
void save(char *filename)
save compiled vocabular memory to file
Definition: ByteCompiler.cpp:15
#define BYTE
byte
Definition: FORTH.h:55
CELL Rp
return stack pointer
Definition: FORTH.c:16