OSDN Git Service

23f7724522363be1062ef4503af34da74befc3bc
[fast-forth/master.git] / ADDON / SD_TOOLS.asm
1 ; -*- coding: utf-8 -*-
2 ; http://patorjk.com/software/taag/#p=display&f=Banner&t=Fast Forth
3
4 ; Fast Forth For Texas Instrument MSP430FRxxxx FRAM devices
5 ; Copyright (C) <2015>  <J.M. THOORENS>
6 ;
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.
11 ;
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.
16 ;
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/>.
19
20
21
22 ; read logical sector and dump it 
23 ; ----------------------------------;
24     FORTHWORD "SECT_D"              ; sector. --            don't forget to add decimal point to your sector number (if < 65536)
25 ; ----------------------------------;
26 SECT_D
27     MOV     TOS,X                   ; X = SectorH
28     MOV     @PSP,W                  ; W = sectorL
29     CALL    #readSectorWX           ; W = SectorLO  X = SectorHI
30 DisplaySector
31     mDOCOL                          ;
32     .word   UDDOT                   ; ud --            display the double number
33     .word   lit,1E00h,lit,200h,DUMP ;    
34     .word   EXIT                    ;
35 ; ----------------------------------;
36
37 ; TIP : How to identify FAT16 or FAT32 SD_Card ?
38 ; 1 CLUSTER <==> FAT16 RootDIR
39 ; 2 CLUSTER <==> FAT32 RootDIR
40 ; ----------------------------------;
41 ; read first sector of Cluster and dump it
42 ; ----------------------------------;
43             FORTHWORD "CLUST_D"     ; cluster.  --         don't forget to add decimal point to your sector number (if < 65536)
44 ; ----------------------------------;
45     MOV     TOS,&ClusterH           ;
46     MOV     @PSP,&ClusterL          ;
47 Clust_ClustProcess
48     CALL    #ComputeClusFrstSect    ;
49     MOV     &SectorL,0(PSP)         ;
50     MOV     &SectorH,TOS            ;
51     JMP     SECT_D                  ;
52 ; ----------------------------------;
53
54 ; dump FAT1 sector of last entry
55 ; ----------------------------------;
56             FORTHWORD "FAT_D"       ;VWXY Display FATsector
57 ; ----------------------------------;
58     SUB     #4,PSP                  ;
59     MOV     TOS,2(PSP)              ;
60     MOV     &FATsector,0(PSP)       ; FATsectorLO
61     ADD     &OrgFAT1,0(PSP)         ;
62     MOV     #0,TOS                  ; FATsectorHI = 0
63     JMP     SECT_D                  ;
64 ; ----------------------------------;
65
66 ;; dump FAT1 sector of last entry
67 ;; ----------------------------------;
68 ;            FORTHWORD "FAT1_D"      ; Display FATsector
69 ;; ----------------------------------;
70 ;    MOV     &OrgFAT1,Y              ;
71 ;AddFATsector                        ;
72 ;    ADD     &FATsector,Y            ; FATsectorLO
73 ;    SUB     #4,PSP                  ;
74 ;    MOV     TOS,2(PSP)              ; save TOS
75 ;    MOV     Y,0(PSP)                ;
76 ;    MOV     #0,TOS                  ; FATsectorHI = 0
77 ;    JMP     SECT_D                  ;
78 ;; ----------------------------------;
79 ;
80 ;; dump FAT1 sector of last entry
81 ;; ----------------------------------;
82 ;            FORTHWORD "FAT2_D"      ; Display FATsector
83 ;; ----------------------------------;
84 ;    MOV     &OrgFAT2,Y              ;
85 ;    JMP     AddFATsector            ;
86 ;; ----------------------------------;
87
88
89
90 ; dump DIR sector of opened file or first sector of current DIR by default
91 ; ----------------------------------;
92             FORTHWORD "DIR_D"       ; Display DIR sector of CurrentHdl or CurrentDir sector by default 
93 ; ----------------------------------;
94     SUB     #4,PSP                  ;
95     MOV     TOS,2(PSP)              ;           save TOS
96     MOV     &DIRClusterL,&ClusterL  ;
97     MOV     &DIRClusterH,&ClusterH  ;
98     JMP     Clust_ClustProcess      ;
99 ; ----------------------------------;
100