OSDN Git Service

v 162, added Conditionnal Compilation and bootloader
[fast-forth/master.git] / ADDON / CoreExt.asm
1 ; -*- coding: utf-8 -*-
2 ; http://patorjk.com/software/taag/#p=display&f=Banner&t=Fast Forth
3
4 ; Fast Forth For Texas Instrument MSP430FRxxxx FRAM devices
5 ; Copyright (C) <2015>  <J.M. THOORENS>
6 ;
7 ; This program is free software: you can redistribute it and/or modify
8 ; it under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
11 ;
12 ; This program is distributed in the hope that it will be useful,
13 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ; GNU General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 ;https://forth-standard.org/standard/core/DotR
21 ;CE .R
22
23 ;https://forth-standard.org/standard/core/Zerone
24 ;CE 0<>
25
26 ;https://forth-standard.org/standard/core/Zeromore
27 ;CE 0>
28
29 ;https://forth-standard.org/standard/core/TwotoR
30 ;CE 2>R
31
32 ;https://forth-standard.org/standard/core/TwoRfrom
33 ;CE 2R>
34
35 ;https://forth-standard.org/standard/core/TwoRFetch
36 ;CE 2R@
37
38 ;https://forth-standard.org/standard/core/ColonNONAME
39 ;CE :NONAME
40
41 ;https://forth-standard.org/standard/core/ne
42 ;CE <>
43
44 ;https://forth-standard.org/standard/core/qDO
45 ;CE ?DO
46
47 ;https://forth-standard.org/standard/core/ACTION-OF
48 ;CE ACTION-OF
49 ;    STATE @ IF 
50 ;        POSTPONE ['] POSTPONE DEFER@ 
51 ;    ELSE 
52 ;        ' DEFER@ 
53 ;    THEN ; IMMEDIATE
54
55         FORTHWORDIMM "ACTION-OF" 
56         mDOCOL
57         .word STATE,FETCH,QBRAN,AOF1 
58         .word BRACKETTICK,COMMA,DEFER@,COMMA,EXIT
59 AOF1    .word TICK,DEFER@,EXIT 
60
61 ;https://forth-standard.org/standard/core/BUFFERColon
62 ;CE BUFFER:
63         FORTHWORD "BUFFER" ; ( u "<name>" -- ; -- addr ) 
64         mDOCOL
65         .word CREATE,ALLOT,EXIT 
66
67 ;Z (C")     -- c-addr run-time code for C"
68 ; get address and length of string.
69 XCQUOTE:    SUB     #2,PSP          ; 1 -- x TOS      ; push old TOS on stack
70             MOV     TOS,0(PSP)      ; 3 -- TOS x        ; and reserve one cell on stack
71             MOV     IP,TOS          ; 2 -- c-addr       ;
72             MOV.B   @IP+,W
73             ADD     W,IP            ; 1 -- addr u       IP=addr+u=addr(end_of_string)
74             BIT     #1,IP           ; 1 -- addr u       IP=addr+u   Carry set/clear if odd/even
75             ADDC    #0,IP           ; 1 -- addr u       IP=addr+u aligned
76             mNEXT                   ; 4  16~
77
78 ;https://forth-standard.org/standard/core/Cq
79 ;CE C"
80             FORTHWORDIMM "C\34"        ; immediate
81 CQUOTE:     mDOCOL
82             .word   lit,XCQUOTE,COMMA
83             .word   BRAN,SQUOTE1
84
85 ;https://forth-standard.org/standard/core/CASE
86 ; CE CASE 
87
88 ;https://forth-standard.org/standard/core/COMPILEComma
89 ;CE COMPILE,
90         FORTHWORD "COMPILE,"
91         MOV #COMMA,PC
92
93 ;https://forth-standard.org/standard/core/DEFERStore
94 ;C DEFER!       xt CFA_DEFER --     ; store xt to the address after DODEFER
95             FORTHWORD "DEFER!"
96 DEFERSTORE: MOV     @PSP+,2(TOS)    ; -- CFA_DEFER          xt --> [CFA_DEFER+2]
97             MOV     @PSP+,TOS       ; --
98             mNEXT
99
100 ;https://forth-standard.org/standard/core/DEFERFetch
101 ;CE DEFER@
102         FORTHWORD "DEFER@"
103 DEFER@  ADD #2,TOS
104         MNEXT
105
106 ;https://forth-standard.org/standard/core/ENDCASE
107 ;CE ENDCASE
108
109 ;https://forth-standard.org/standard/core/ENDOF
110 ;CE ENDOF
111
112 ;https://forth-standard.org/standard/core/HOLDS
113 ;CE HOLDS
114
115 ;https://forth-standard.org/standard/core/MARKER
116 ;CE MARKER
117
118 ;https://forth-standard.org/standard/core/OF
119 ;CE OF
120
121 ;https://forth-standard.org/standard/core/PARSE
122 ;CE PARSE
123
124 ;https://forth-standard.org/standard/core/PARSE-NAME
125 ;CE PARSE-NAME
126
127 ;https://forth-standard.org/standard/core/PICK
128 ;CE PICK
129
130 ;https://forth-standard.org/standard/core/REFILL
131 ;CE REFILL
132
133 ;https://forth-standard.org/standard/core/RESTORE-INPUT
134 ;CE RESTORE-INPUT
135
136 ;https://forth-standard.org/standard/core/ROLL
137 ;CE ROLL
138
139 ;https://forth-standard.org/standard/core/SAVE-INPUT
140 ;CE SAVE-INPUT
141
142 ;https://forth-standard.org/standard/core/SOURCE-ID
143 ;CE SOURCE-ID
144
145 ;https://forth-standard.org/standard/core/Seq
146 ;CE S\"
147
148 ;https://forth-standard.org/standard/core/TO
149 ;CE TO
150         FORTHWORD "TO"
151         MOV #IS,PC
152
153 ;https://forth-standard.org/standard/core/TRUE
154 ;CE TRUE
155
156 ;https://forth-standard.org/standard/core/TUCK
157 ;CE TUCK
158
159 ;https://forth-standard.org/standard/core/UDotR
160 ;CE U.R
161
162 ;https://forth-standard.org/standard/core/Umore
163 ;CE U>
164
165 ;https://forth-standard.org/standard/core/UNUSED
166 ;CE UNUSED  
167
168 ;https://forth-standard.org/standard/core/VALUE
169 ;CE VALUE
170         FORTHWORD "VALUE"
171         MOV #CONSTANT,PC
172
173 ;https://forth-standard.org/standard/core/WITHIN
174 ;CE WITHIN
175
176 ;https://forth-standard.org/standard/core/BracketCOMPILE
177 ;CE [COMPILE]
178
179