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/>.
22 .include "ADDON\ALIGNMENT.asm"
25 .include "ADDON\ARITHMETIC.asm"
28 .include "ADDON\PORTABILITY.asm"
31 .include "ADDON\DOUBLE.asm"
34 ;C INVERT x1 -- x2 bitwise inversion
39 ;C LSHIFT x1 u -- x2 logical L shift u places
42 AND #1Fh,TOS ; no need to shift more than 16
50 ;C RSHIFT x1 u -- x2 logical R shift u places
53 AND #1Fh,TOS ; no need to shift more than 16
55 RSH_1: BIC #1,SR ; CLRC
62 ;C 1+ n1/u1 -- n2/u2 add 1 to TOS
67 ;C 1- n1/u1 -- n2/u2 subtract 1 from TOS
72 ;C 2* x1 -- x2 arithmetic left shift
77 ;C 2/ x1 -- x2 arithmetic right shift
82 ;C MAX n1 n2 -- n3 signed maximum
84 MAX: CMP @PSP,TOS ; n2-n1
89 ;C MIN n1 n2 -- n3 signed minimum
91 MIN: CMP @PSP,TOS ; n2-n1
96 ;C +! n/u a-addr -- add to memory
98 PLUSSTORE ADD @PSP+,0(TOS)
102 ;C CHAR -- char parse ASCII character
105 .word FBLANK,WORDD,ONEPLUS,CFETCH,EXIT
107 ;C [CHAR] -- compile character literal
108 FORTHWORDIMM "[CHAR]" ; immediate
114 ;C FILL c-addr u char -- fill memory with char
116 FILL MOV @PSP+,X ; count
117 MOV @PSP+,W ; address
120 FILL_1: MOV.B TOS,0(W) ; store char in memory
124 FILL_X: MOV @PSP+,TOS ; pop new TOS
132 DECIMAL MOV #10,&BASE
135 ;C ( \ -- paren ; skip input until )
136 FORTHWORDIMM "\40" ; immediate
138 .word lit,')',WORDD,DROP,EXIT
142 ; .( \ -- dotparen ; type comment immediatly.
143 FORTHWORDIMM ".\40" ; immediate
152 ; .( \ -- dotparen ; type comment immediatly.
153 FORTHWORDIMM ".\40" ; immediate
160 ;C SOURCE -- adr u current input buffer
165 MOV &SOURCE_ADR,0(PSP)
168 ; >BODY -- PFA leave PFA of created word