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/>.
23 .IFNDEF ANS_CORE_COMPLIANT
25 ;https://forth-standard.org/standard/core/MAX
26 ;C MAX n1 n2 -- n3 signed maximum
28 MAX: CMP @PSP,TOS ; n2-n1
33 ;https://forth-standard.org/standard/core/MIN
34 ;C MIN n1 n2 -- n3 signed minimum
36 MIN: CMP @PSP,TOS ; n2-n1
41 .ENDIF ; ANS_CORE_COMPLIANT
43 ;https://forth-standard.org/standard/core/UDotR
44 ;X U.R u n -- display u unsigned in n width
47 .word TOR,LESSNUM,lit,0,NUM,NUMS,NUMGREATER
48 .word RFROM,OVER,MINUS,lit,0,MAX,SPACES,TYPE
51 ;https://forth-standard.org/standard/tools/DUMP
56 ADD @PSP,TOS ; compute end address
57 AND #0FFF0h,0(PSP) ; compute start address
59 .word SWAP,xdo ; generate line
61 .word II,lit,7,UDOTR,SPACE ; generate address
62 .word II,lit,10h,PLUS,II,xdo ; display 16 bytes
63 DUMP2 .word II,CFETCH,lit,3,UDOTR
66 .word II,lit,10h,PLUS,II,xdo ; display 16 chars
68 .word lit,7Eh,MIN,FBLANK,MAX,EMIT
70 .word lit,10h,xploop,DUMP1
71 .word RFROM,FBASE,STORE
76 FORTHWORD "{SD_TOOLS}"
79 ; read logical sector and dump it
80 ; ----------------------------------;
81 FORTHWORD "SECTOR" ; sector. -- don't forget to add decimal point to your sector number (if < 65536)
82 ; ----------------------------------;
84 MOV TOS,X ; X = SectorH
85 MOV @PSP,W ; W = sectorL
86 CALL #readSectorWX ; W = SectorLO X = SectorHI
89 .word LESSNUM,NUMS,NUMGREATER ; ud -- display the double number
91 .word lit,SD_BUF,lit,200h,DUMP;
93 ; ----------------------------------;
95 ; TIP : How to identify FAT16 or FAT32 SD_Card ?
96 ; 1 CLUSTER <==> FAT16 RootDIR
97 ; 2 CLUSTER <==> FAT32 RootDIR
98 ; ----------------------------------;
99 ; read first sector of Cluster and dump it
100 ; ----------------------------------;
101 FORTHWORD "CLUSTER" ; cluster. -- don't forget to add decimal point to your sector number (if < 65536)
102 ; ----------------------------------;
106 CALL #ComputeClusFrstSect ;
107 MOV &SectorL,0(PSP) ;
110 ; ----------------------------------;
112 ; dump FAT1 sector of last entry
113 ; ----------------------------------;
114 FORTHWORD "FAT" ;VWXY Display first FATsector
115 ; ----------------------------------;
118 MOV &OrgFAT1,0(PSP) ;
119 MOV #0,TOS ; FATsectorHI = 0
121 ; ----------------------------------;
123 ;; dump FAT1 sector of last entry
124 ;; ----------------------------------;
125 ; FORTHWORD "FAT" ; Display FATsector
126 ;; ----------------------------------;
130 ; MOV TOS,2(PSP) ; save TOS
132 ; MOV #0,TOS ; FATsectorHI = 0
134 ;; ----------------------------------;
136 ;; dump FAT1 sector of last entry
137 ;; ----------------------------------;
138 ; FORTHWORD "FAT2" ; Display FATsector
139 ;; ----------------------------------;
142 ;; ----------------------------------;
146 ; dump DIR sector of opened file or first sector of current DIR by default
147 ; ----------------------------------;
148 FORTHWORD "DIR" ; Display DIR sector of CurrentHdl or CurrentDir sector by default
149 ; ----------------------------------;
151 MOV TOS,2(PSP) ; save TOS
152 MOV &DIRClusterL,&ClusterL ;
153 MOV &DIRClusterH,&ClusterH ;
154 JMP Clust_ClustProcess ;
155 ; ----------------------------------;