-
Notifications
You must be signed in to change notification settings - Fork 66
/
EEALIAS
89 lines (71 loc) · 1.92 KB
/
EEALIAS
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
\ EEPROM MODE STM8 eForth memory ALIAS utility words
\ refer to github.com/TG9541/stm8ef/blob/master/LICENSE.md
\
\ * define ALIAS words in the EEPROM,
\ * compilation aborts if the compilation of non-ALIAS words is attemted
\ note: the STM8 resets when executing plain compiled words from EEPROM!
\ * return to RAM MODE with EEND when done
\ * remove ALIAS words in EEPROM from dictionary with EERESET
\ beware: any of the words #required here won't be in the EEPROM
#require WIPE
#require CP
#require CONTEXT
#require LAST
#require ULOCK
#require LOCK
#require ULOCKF
#require LOCKF
#require ABORT"
#require EESTART
EESTART 20 + CONSTANT EELINK \ reserve some of the EEPROM for application
: setroot ( a -- )
\ set a as dictionary root in Flash memory
[ ( ! used as anchor ) ' ! 4 - @ ] LITERAL BEGIN
DUP 2 - @ DUP 0<
WHILE SWAP DROP
REPEAT DROP 2 -
( la a ) ULOCKF ! LOCKF
;
: EEND ( -- )
\ link dictionary, end EEPROM mode, and return to RAM mode with WIPE
0 EELINK ! LOCK
CONTEXT @ setroot
WIPE
;
: EERESET ( -- )
\ remove link to ALIAS dictionary in EEPROM
0 setroot
;
: NVM ( -- )
EEND
1 ABORT" NVM IN EEPROM MODE"
;
: CONSTANT ( -- )
EEND
1 ABORT" CONSTANT IN EEPROM MODE"
;
: VARIABLE ( -- )
EEND
1 ABORT" VARIABLE IN EEPROM MODE"
;
: ; ( -- )
EEND
1 ABORT" NON-ALIAS IN EEPROM MODE"
; IMMEDIATE
\ initialize and link dictionary in EEPROM
EERESET \ unlink any existing dictionary in the EEPROM
ULOCK \ keep the EEPROM unlocked from here on
CONTEXT @ EELINK ! \ create dummy word in EEPROM
EELINK 2 + 0 OVER ! \ word length=0
DUP LAST ! \ set context to dummy word
DUP CONTEXT !
1 + CP ! \ from here on, use EEPROM instead of RAM
\ now #require some ALIAS files, finalize with EEND
\\ Example:
#include EEALIAS
\ load ALIAS words
#require SPACES
#require DIGIT
#require DNEGATE
\ done: close and return to RAM mode
EEND