nanoFORTH
v2.2
|
nanoForth Assembler class More...
#include "n4.h"
Go to the source code of this file.
Namespaces | |
N4Asm | |
Macros | |
#define | N4_DOES_META 1 |
#define | N4_USE_GOTO 0 |
#define | XT(a) ((a) + sizeof(IU) + 3) /** adr + lnk[2] + name[3] */ |
Enumerations | |
enum | N4OP { TKN_IMM = 0, TKN_WRD, TKN_PRM, TKN_NUM, TKN_EXT, TKN_ERR } |
enum | N4_EXT_OP { I_NOP = 0, I_SEM = 10, I_DQ = 31, I_SQ = 32, I_DO = 55, I_I = 61, I_FOR = 62, I_LIT = 63 } |
Functions | |
void | N4Asm::save (U8 autorun=0) |
persist user dictionary to EEPROM More... | |
U16 | N4Asm::load (U8 autorun=0) |
restore user dictionary from EEPROM More... | |
IU | N4Asm::reset () |
reset internal pointers (for BYE) More... | |
N4OP | N4Asm::parse (U8 *tkn, IU *rst, U8 run) |
Instruction decoder. More... | |
void | N4Asm::compile (IU *rp0) |
Forth compiler. More... | |
void | N4Asm::variable () |
create a variable on dictionary More... | |
void | N4Asm::constant (DU v) |
void | N4Asm::create () |
meta compiler More... | |
void | N4Asm::comma (DU v) |
compile a 16-bit value onto dictionary More... | |
void | N4Asm::ccomma (DU v) |
More... | |
void | N4Asm::does (IU xt) |
More... | |
void | N4Asm::dot_str () |
IU | N4Asm::query () |
dictionary, string list scanners More... | |
void | N4Asm::words () |
display words in dictionary More... | |
void | N4Asm::forget () |
forgets word in the dictionary More... | |
void | N4Asm::see () |
decode colon word More... | |
IU | N4Asm::trace (IU adr, U8 ir, char delim=0) |
print execution tracing info More... | |
Variables | |
constexpr IU | LFA_END = 0xffff |
end of link field More... | |
Opcode Masks | |
constexpr U8 | CTL_BITS = 0xc0 |
1100 0000, JMP - 11nn xxxx, PRM - 10nn nnnn, NUM - 0nnn nnnn More... | |
constexpr U8 | JMP_OPS = 0xc0 |
1100 0000 More... | |
constexpr U8 | PRM_OPS = 0x80 |
1000 0000 More... | |
constexpr U8 | JMP_MASK = 0xf0 |
11nn xxxx, nn - CALL 00, CDJ 01, UDJ 10, NXT 11 More... | |
constexpr U8 | PRM_MASK = 0x3f |
00nn nnnn, 6-bit primitive opcodes More... | |
constexpr IU | ADR_MASK = 0x0fff |
0000 aaaa aaaa aaaa 12-bit address in 16-bit branching instructions More... | |
Opcode Prefixes | |
constexpr U8 | OP_CALL = 0xc0 |
1100 0000 More... | |
constexpr U8 | OP_CDJ = 0xd0 |
1101 0000 More... | |
constexpr U8 | OP_UDJ = 0xe0 |
1110 0000 More... | |
constexpr U8 | OP_NXT = 0xf0 |
1111 0000 More... | |
nanoForth Assembler class
#define N4_DOES_META 1 |
@Note 1: N4_DOES_META flag enable meta-programming, it takes 6 opcodes slots i.e. 55~60 can be disabled if other opcodes need the slots @Note 2: N4_USE_GOTO flag use computed goto for primitive word invocation, speeds up 5%, but takes extra 128 bytes of RAM, can be disabled if some library needs extra memory enable meta programming
#define N4_USE_GOTO 0 |
use computed goto
#define XT | ( | a | ) | ((a) + sizeof(IU) + 3) /** adr + lnk[2] + name[3] */ |
enum N4OP |
enum N4_EXT_OP |
opcodes for loop control (in compiler mode) Note: sequence in-sync with N4Asm::N4_WORDS, and N4VM::_invoke
Enumerator | |
---|---|
I_NOP | extended opcode (used by for...nxt loop) NOP means EXIT |
I_SEM | ; semi-colon |
I_DQ | ." dot_string |
I_SQ | S" do_string. |
I_DO | DO> |
I_I | 61, loop counter |
I_FOR | 62 |
I_LIT | 63 = 0x3f 3-byte literal |
|
constexpr |
1100 0000, JMP - 11nn xxxx, PRM - 10nn nnnn, NUM - 0nnn nnnn
|
constexpr |
1100 0000
|
constexpr |
1000 0000
|
constexpr |
11nn xxxx, nn - CALL 00, CDJ 01, UDJ 10, NXT 11
|
constexpr |
00nn nnnn, 6-bit primitive opcodes
|
constexpr |
0000 aaaa aaaa aaaa 12-bit address in 16-bit branching instructions
|
constexpr |
1100 0000
|
constexpr |
1101 0000
|
constexpr |
1110 0000
|
constexpr |
1111 0000
|
constexpr |
end of link field