1 ; ------------------------------------------------
2 ; BASIC TOOLS for SD Card : DIR FAT SECTOR CLUSTER
3 ; ------------------------------------------------
6 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
7 \ MSP_EXP430FR4133 CHIPSTICK_FR2433
9 \ MY_MSP430FR5738_1 MY_MSP430FR5738 MY_MSP430FR5948 MY_MSP430FR5948_1
14 \ R4 to R7 must be saved before use and restored after
15 \ scratch registers Y to S are free for use
16 \ under interrupt, IP is free for use
18 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, R7, R6, R5, R4
19 \ example : PUSHM IP,Y
21 \ POPM order : R4, R5, R6, R7, Y, X, W, T, S, IP,TOS,PSP
24 \ FORTH conditionnals: unary{ 0= 0< 0> }, binary{ = < > U< }
26 \ ASSEMBLER conditionnal usage with IF UNTIL WHILE S< S>= U< U>= 0= 0<> 0>=
28 \ ASSEMBLER conditionnal usage with ?JMP ?GOTO S< S>= U< U>= 0= 0<> <0
33 [DEFINED] {SD_TOOLS} [IF] {SD_TOOLS} [THEN] \ remove {SD_TOOLS} if outside core
35 [DEFINED] ASM [DEFINED] LOAD" AND [UNDEFINED] {SD_TOOLS} AND [IF] \ "
39 [UNDEFINED] MAX [IF] \ MAX and MIN are defined in {UTILITY}
41 CODE MAX \ n1 n2 -- n3 signed maximum
49 CODE MIN \ n1 n2 -- n3 signed minimum
59 [UNDEFINED] U.R [IF] \ defined in {UTILITY}
60 : U.R \ u n -- display u unsigned in n width (n >= 2)
62 R> OVER - 0 MAX SPACES TYPE
67 [UNDEFINED] DUMP [IF] \ defined in {UTILITY}
68 : DUMP \ adr n -- dump memory
73 I 7 U.R SPACE \ generate address
74 I $10 + I \ display 16 bytes
77 I $10 + I \ display 16 chars
78 DO I C@ $7E MIN BL MAX EMIT LOOP
86 \ display content of a sector
87 \ ----------------------------------\
88 CODE SECTOR \ sector. -- don't forget to add decimal point to your sector number
89 \ ----------------------------------\
90 MOV TOS,X \ X = SectorH
91 MOV @PSP,W \ W = sectorL
92 CALL &ReadSectorWX \ W = SectorLO X = SectorHI
94 <# #S #> TYPE SPACE \ ud -- display the double number
95 SD_BUF $200 DUMP CR ; \ then dump the sector
96 \ ----------------------------------\
99 \ ----------------------------------\
100 CODE FAT \ Display CurFATsector
101 \ ----------------------------------\
104 MOV &CurFATsector,0(PSP) \ FATsectorLO
105 ADD &OrgFAT1,0(PSP) \
106 MOV #0,TOS \ FATsectorHI = 0
107 JMP SECTOR \ jump to a defined word
109 \ ----------------------------------\
112 \ display first sector of a Cluster
113 \ ----------------------------------\
114 CODE CLUSTER \ cluster. -- don't forget to add decimal point to your cluster number
115 \ ----------------------------------\
116 MOV.B &SecPerClus,W \ 3 SecPerClus(5-1) = multiplicator
119 U< IF \ case of SecPerClus>1
121 ADD X,X \ 5 (RLA) shift one left MULTIPLICANDlo16
122 ADDC TOS,TOS \ 1 (RLC) shift one left MULTIPLICANDhi8
123 RRA W \ 1 shift one right multiplicator
124 U>= UNTIL \ carry set
126 ADD &OrgClusters,X \ add OrgClusters = sector of virtual cluster 0 (word size)
128 ADDC #0,TOS \ don't forget carry
129 JMP SECTOR \ jump to a defined word
131 \ ----------------------------------\
134 \ ----------------------------------\
135 CODE DIR \ Display CurrentDir first sector
136 \ ----------------------------------\
138 MOV TOS,2(PSP) \ save TOS
139 MOV &DIRclusterL,0(PSP) \
140 MOV &DIRclusterH,TOS \
143 \ ----------------------------------\
148 ; added : FAT to DUMP first sector of FAT1 and DIR for that of current DIRectory.
149 ; added : SECTOR to DUMP a sector and CLUSTER for first sector of a cluster:
150 ; include a decimal point to force 32 bits number, example : .2 CLUSTER