Go to the documentation of this file.
6 #ifndef __SRC_N4_CORE_H
7 #define __SRC_N4_CORE_H
18 #define show(s) { io->print(F(s)); io->flush(); }
20 #define show(s) log(s)
22 #define ENC8(p, c) (*(U8*)(p)++=(U8)(c))
37 #define ENCA(p, a) { IU x=(IU)(a); ENC8(p,(x)>>8); ENC8(p,(x)&0xff); }
38 #define GETA(p) (((IU)(*(U8*)(p))<<8) + *((U8*)(p)+1))
39 #define STORE(p, v) { DU x=(DU)(v); ENC8(p,(x)>>8); ENC8(p,(x)&0xff); }
40 #define FETCH(p) (((DU)(*(U8*)(p))<<8) + *((U8*)(p)+1))
113 #endif //__SRC_N4_CORE_H
N4Task vm
VM context.
Definition: n4_core.cpp:23
U16 a_in(U16 p)
fetch from analog port
Definition: n4_core.cpp:99
U8 scan(U8 *tkn, const char *lst, IU *id)
Definition: n4_core.cpp:283
constexpr U16 N4_DIC_SZ
Definition: n4_core.h:12
constexpr U16 N4_STK_SZ
Definition: n4_core.h:13
char key()
Arduino's Serial.getchar(), yield to user tasks when waiting.
Definition: n4_core.cpp:65
void clear_tib()
reset input buffer
Definition: n4_core.cpp:172
constexpr U16 N4_TIB_SZ
Definition: n4_core.h:14
void d_str(U8 *p)
handle dot string (byte-stream leading with length)
Definition: n4_core.cpp:113
U8 number(U8 *str, DU *num)
Definition: n4_core.cpp:148
U8 * get_token(U8 rst)
get a token from console input
Definition: n4_core.cpp:246
U8 trc
tracing control flag
Definition: n4_core.cpp:28
void set_hex(U8 f)
enable/disable hex numeric radix
void set_io(Stream *s)
initialize or redirect IO stream
U16 d_in(U16 p)
fetch from GPIO port
Definition: n4_core.cpp:81
void d_out(U16 p, U16 v)
send output to GPIO ports
Definition: n4_core.cpp:82
void d_mem(U8 *base, U8 *p0, IU sz, U8 delim)
Definition: n4_core.cpp:120
void d_chr(char c)
print a char to console
Definition: n4_core.cpp:70
DU * sp
top of data stack
Definition: n4_core.h:47
void mstat()
display MMU statistics
Definition: n4_core.cpp:46
Definition: n4_core.cpp:18
S16 DU
16-bit data unit (CELL)
Definition: n4.h:76
constexpr U16 N4_RAM_SZ
Definition: n4_core.h:15
void d_u8(U8 c)
print a 8-bit hex number
Definition: n4_core.cpp:115
void d_adr(IU a)
print a 12-bit address
Definition: n4_core.cpp:77
void d_num(DU n)
sent a number literal to console
Definition: n4_core.cpp:79
U8 ok()
check whether input buffer is empty
Definition: n4_core.cpp:218
uint16_t U16
16-bit unsigned integer, for return stack, and pointers
Definition: n4.h:66
U8 dic[N4_RAM_SZ]
base of dictionary
Definition: n4_core.cpp:22
void d_pin(U16 p, U16 v)
set pin a given pinMode (INPUT, OUTPUT)
Definition: n4_core.cpp:80
Stream * io
default to Arduino Serial Monitor
Definition: n4_core.cpp:27
char uc(char c)
Definition: n4_core.cpp:40
void a_out(U16 p, U16 v)
send output to GPIO ports
Definition: n4_core.cpp:100
void d_nib(U8 n)
print a nibble
Definition: n4_core.cpp:114
uint8_t U8
8-bit unsigned integer, for char and short int
Definition: n4.h:65
IU * rp
base of return stack
Definition: n4_core.h:46
void d_ptr(U8 *p)
print a pointer
Definition: n4_core.cpp:78
void d_name(U8 *p)
print 3 characters name
Definition: n4_core.cpp:132
void set_ucase(U8 uc)
set case sensitiveness
nanoForth main controller
U16 IU
16-bit instruction unit (ADDR)
Definition: n4.h:75
void set_pre(const char *code)
set embedded Forth code
Definition: n4_core.cpp:36