1 ; -*- coding: utf-8 -*-
2 ; http://patorjk.com/software/taag/#p=display&f=Banner&t=Fast Forth
4 ; Fast Forth For Texas Instrument MSP430FRxxxx FRAM devices
5 ; Copyright (C) <2015> <J.M. THOORENS>
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.
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.
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/>.
21 FORTHWORD "{ANS_COMP}"
25 .include "ADDON/ARITHMETIC.asm"
28 .include "ADDON/ALIGNMENT.asm"
31 .include "ADDON/PORTABILITY.asm"
34 .include "ADDON/DOUBLE.asm"
37 ;https://forth-standard.org/standard/core/AND
38 ;C AND x1 x2 -- x3 logical AND
43 ;https://forth-standard.org/standard/core/OR
44 ;C OR x1 x2 -- x3 logical OR
49 ;https://forth-standard.org/standard/core/XOR
50 ;C XOR x1 x2 -- x3 logical XOR
55 ;https://forth-standard.org/standard/core/INVERT
56 ;C INVERT x1 -- x2 bitwise inversion
61 ;https://forth-standard.org/standard/core/LSHIFT
62 ;C LSHIFT x1 u -- x2 logical L shift u places
65 AND #1Fh,TOS ; no need to shift more than 16
73 ;https://forth-standard.org/standard/core/RSHIFT
74 ;C RSHIFT x1 u -- x2 logical R shift u places
77 AND #1Fh,TOS ; no need to shift more than 16
79 RSH_1: BIC #1,SR ; CLRC
86 ;https://forth-standard.org/standard/core/TwoTimes
87 ;C 2* x1 -- x2 arithmetic left shift
92 ;https://forth-standard.org/standard/core/TwoDiv
93 ;C 2/ x1 -- x2 arithmetic right shift
98 ;https://forth-standard.org/standard/core/MAX
99 ;C MAX n1 n2 -- n3 signed maximum
101 MAX: CMP @PSP,TOS ; n2-n1
106 ;https://forth-standard.org/standard/core/MIN
107 ;C MIN n1 n2 -- n3 signed minimum
109 MIN: CMP @PSP,TOS ; n2-n1
114 ;https://forth-standard.org/standard/core/PlusStore
115 ;C +! n/u a-addr -- add to memory
117 PLUSSTORE ADD @PSP+,0(TOS)
121 ;https://forth-standard.org/standard/core/CHAR
122 ;C CHAR -- char parse ASCII character
125 .word FBLANK,WORDD,ONEPLUS,CFETCH,EXIT
127 ;https://forth-standard.org/standard/core/BracketCHAR
128 ;C [CHAR] -- compile character literal
129 FORTHWORDIMM "[CHAR]" ; immediate
135 ;https://forth-standard.org/standard/core/FILL
136 ;C FILL c-addr u char -- fill memory with char
138 FILL MOV @PSP+,X ; count
139 MOV @PSP+,W ; address
142 FILL_1: MOV.B TOS,0(W) ; store char in memory
146 FILL_X: MOV @PSP+,TOS ; pop new TOS
149 ;https://forth-standard.org/standard/core/HEX
154 ;https://forth-standard.org/standard/core/DECIMAL
156 DECIMAL MOV #10,&BASE
159 ;https://forth-standard.org/standard/core/p
160 ;C ( \ -- paren ; skip input until )
161 FORTHWORDIMM "\40" ; immediate
163 .word lit,')',WORDD,DROP,EXIT
165 ;https://forth-standard.org/standard/core/Dotp
166 ; .( \ -- dotparen ; type comment immediatly.
167 FORTHWORDIMM ".\40" ; immediate
183 ;https://forth-standard.org/standard/core/SOURCE
184 ;C SOURCE -- adr u current input buffer
189 MOV &SOURCE_ADR,0(PSP)
192 ;https://forth-standard.org/standard/core/toBODY
193 ; >BODY -- PFA leave PFA of created word
199 ;https://forth-standard.org/standard/core/toIN
200 ;C >IN -- a-addr holds offset in input stream
203 .word TOIN ; VARIABLE address in RAM space
207 ;https://forth-standard.org/standard/core/PAD