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) <2017> <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 ;Z SD_ACCEPT addr addr len -- addr' len' get line to interpret from a SD Card file
22 ; note : addr = TIB, addr' = PAD
23 ; defered word ACCEPT is redirected here by the word LOAD"
24 ; sequentially move an input line ended by CRLF from BUFFER to PAD
25 ; if end of buffer is reached before CRLF, asks Read_HandledFile to fill buffer with next sector
26 ; then move the end of the line.
27 ; when all LOAD"ed files are read, redirects defered word ACCEPT to (ACCEPT) and restore interpret pointers.
30 ; used variables : BufferPtr, BufferLen
32 ; ----------------------------------;
33 ; FORTHWORD "SD_ACCEPT" ; TIB TIB TIB_LEN -- PAD|SDIB len'
34 ; ----------------------------------;
35 SD_ACCEPT ; sequentially move from BUFFER to SDIB (PAD if RAM=1k) a line of chars delimited by CRLF
36 ; ----------------------------------; up to TIB_LEN = 80 chars
38 MOV #SDA_YEMIT_RET,IP ; set YEMIT return
39 ; ----------------------------------;
41 ; ----------------------------------;
42 MOV &CurrentHdl,T ; prepare a link for the next LOADed file...
43 MOV &BufferPtr,HDLW_BUFofst(T) ; ...see usage : HandleComplements
44 ; ----------------------------------; -- TIB TIB len
46 MOV W,2(PSP) ; -- StringOrg' TIB TIB_LEN
47 MOV TOS,0(PSP) ; -- StringOrg' TIB_LEN TIB_LEN
48 MOV #0,TOS ; -- StringOrg' TIB_LEN Count
49 ; ----------------------------------;
50 SDA_InitSrcAddr ; <== SDA_GetFileNextSector
51 ; ----------------------------------;
52 MOV &BufferPtr,X ; X=src
54 ; ----------------------------------;
56 ; ----------------------------------;
58 SUB #2,IP ; 1 restore YEMIT return
59 ; ----------------------------------;
61 ; ----------------------------------;
62 CMP &BufferLen,X ; 3 BufferPtr >= BufferLen ?
63 JHS SDA_GetFileNextSector ; 2 yes
64 MOV.B BUFFER(X),Y ; 3 Y = char
65 ADD #1,X ; 1 increment input BufferPtr
66 CMP.B #32,Y ; 2 ascii printable char ?
67 JHS SDA_MoveChar ; 2 yes
68 CMP.B #10,Y ; 2 control char = 'LF' ?
69 JNZ SDA_ComputeChar ; 2 no
70 ; ----------------------------------;
72 ; ----------------------------------;
73 MOV X,&BufferPtr ; yes save BufferPtr for next line
74 ADD #2,PSP ; -- StringOrg' len'
76 MOV @IP+,PC ; ===> unique output
77 ; ----------------------------------;
79 ; ----------------------------------;
80 CMP @PSP,TOS ; 2 count = TIB_LEN ?
81 JZ YEMIT ; 2 yes, don't move char to dst
82 MOV.B Y,0(W) ; 3 move char to dst
83 ADD #1,W ; 1 increment dst addr
84 ADD #1,TOS ; 1 increment count of moved chars
85 JMP YEMIT ; 9/6~ send echo to terminal if ECHO, do nothing if NOECHO
86 ; ----------------------------------; 32/29~ char loop, add 14~ for readsectorW ==> 46/43~ ==> 174/186 kbytes/s @ 8MHz
87 SDA_GetFileNextSector ; StringOrg' TIB_LEN Count --
88 ; ----------------------------------;
90 CALL #Read_File ; that resets BufferPtr
91 MOV @RSP+,W ; restore dst
92 JMP SDA_InitSrcAddr ; loopback to end the line
93 ; ----------------------------------;
95 ;https://forth-standard.org/standard/core/ACCEPT
96 ;C ACCEPT addr addr len -- addr' len' get line at addr to interpret len' chars
98 ACCEPT MOV #PARENACCEPT,PC
100 ;C (ACCEPT) addr addr len -- addr len' get len' (up to len) chars from terminal (TERATERM.EXE) via USBtoUART bridge