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 len -- PAD|SDIB len'
34 ; ----------------------------------;
35 SD_ACCEPT ; sequentially move from BUFFER to SDIB (or PAD) a line of chars delimited by CRLF
36 ; ----------------------------------;
38 MOV #SDA_YEMIT_RET,IP ; set YEMIT return
39 ; ----------------------------------;
41 ; ----------------------------------;
42 MOV &CurrentHdl,T ; prepare link for any next LOAD"ed file...
43 MOV &BufferPtr,HDLW_BUFofst(T) ; ...see usage : HandleComplements
44 ; ----------------------------------; -- TIB TIB len
45 .IFDEF RAM_1K ; use PAD as SD Input Buffer because the lack of RAM
47 MOV #PAD_SIZE-4,0(PSP) ; -- TIB max_count len
48 .ELSEIF ; use SDIB as SD Input Buffer
50 MOV #SDIB_SIZE-4,0(PSP) ; -- TIB max_count len
52 MOV W,2(PSP) ; -- StringOrg' max_count len
53 MOV #0,TOS ; -- StringOrg' max_count Count
54 ; ----------------------------------;
55 SDA_InitSrcAddr ; <== SDA_GetFileNextSector
56 ; ----------------------------------;
57 CMP #0,&BufferLen ; test if input buffer is empty (EOF)
58 JZ SDA_GoToInterpret ; yes
59 MOV &BufferPtr,X ; X=src
61 ; ----------------------------------;
63 ; ----------------------------------;
65 SUB #2,IP ; 1 restore YEMIT return
66 ; ----------------------------------;
68 ; ----------------------------------;
69 CMP &BufferLen,X ; 3 BufferPtr >= BufferLen ?
70 JHS SDA_GetFileNextSector ; 2 yes
71 MOV.B BUFFER(X),Y ; 3 Y = char
72 ADD #1,X ; 1 increment input BufferPtr
73 CMP.B #32,Y ; 2 ascii printable char ?
74 JHS SDA_MoveChar ; 2 yes
75 CMP.B #10,Y ; control char = 'LF' ?
76 JNZ SDA_ComputeChar ; no
77 ; ----------------------------------;
79 ; ----------------------------------;
80 MOV X,&BufferPtr ; yes save BufferPtr for next line
81 ; ----------------------------------;
82 SDA_GoToInterpret ; -- StringOrg' max_count len'
83 ; ----------------------------------;
84 ADD #2,PSP ; -- StringOrg' len'
86 MOV @IP+,PC ; ===> unique output
87 ; ----------------------------------;
89 ; ----------------------------------;
90 CMP TOS,0(PSP) ; 3 count = max_chars_count ?
91 JZ YEMIT ; 2 yes, don't move char to dst
92 MOV.B Y,0(W) ; 3 move char to dst
93 ADD #1,W ; 1 increment dst addr
94 ADD #1,TOS ; 1 increment count of moved chars
95 JMP YEMIT ; 9/6~ send echo to terminal if ECHO, do nothing if NOECHO
96 ; ----------------------------------; 33/30~ char loop, add 14~ for readsectorW ==> 47/44~ ==> 21/23 kbytes/s / MHz
97 SDA_GetFileNextSector ;
98 ; ----------------------------------;
100 CALL #Read_File ; that resets BufferPtr
101 MOV @RSP+,W ; restore dst
102 JMP SDA_InitSrcAddr ; loopback to end the line
103 ; ----------------------------------;
106 ;C ACCEPT addr addr len -- addr' len' get line at addr to interpret len' chars
108 ACCEPT MOV #PARENACCEPT,PC
110 ;C (ACCEPT) addr addr len -- addr len' get len' (up to len) chars from terminal (TERATERM.EXE) via USBtoUART bridge