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 MSP_EXP430FR2433 MSP_EXP430FR2355
11 \ R4 to R7 must be saved before use and restored after
12 \ scratch registers Y to S are free for use
13 \ under interrupt, IP is free for use
15 \ PUSHM order : PSP,TOS, IP, S, T, W, X, Y, R7, R6, R5, R4
16 \ example : PUSHM IP,Y
18 \ POPM order : R4, R5, R6, R7, Y, X, W, T, S, IP,TOS,PSP
21 \ FORTH conditionnals: unary{ 0= 0< 0> }, binary{ = < > U< }
23 \ ASSEMBLER conditionnal usage with IF UNTIL WHILE S< S>= U< U>= 0= 0<> 0>=
25 \ ASSEMBLER conditionnal usage with ?JMP ?GOTO S< S>= U< U>= 0= 0<> <0
30 [DEFINED] {SD_TOOLS} [IF] {SD_TOOLS} [THEN] \ remove {SD_TOOLS} if outside core
32 [DEFINED] ASM [DEFINED] LOAD" AND [UNDEFINED] {SD_TOOLS} AND [IF] \ "
36 [UNDEFINED] MAX [IF] \ MAX and MIN are defined in {UTILITY}
38 CODE MAX \ n1 n2 -- n3 signed maximum
46 CODE MIN \ n1 n2 -- n3 signed minimum
56 [UNDEFINED] U.R [IF] \ defined in {UTILITY}
57 : U.R \ u n -- display u unsigned in n width (n >= 2)
59 R> OVER - 0 MAX SPACES TYPE
64 [UNDEFINED] DUMP [IF] \ defined in {UTILITY}
65 : DUMP \ adr n -- dump memory
70 I 7 U.R SPACE \ generate address
71 I $10 + I \ display 16 bytes
74 I $10 + I \ display 16 chars
75 DO I C@ $7E MIN BL MAX EMIT LOOP
83 \ display content of a sector
84 \ ----------------------------------\
85 CODE SECTOR \ sector. -- don't forget to add decimal point to your sector number
86 \ ----------------------------------\
87 MOV TOS,X \ X = SectorH
88 MOV @PSP,W \ W = sectorL
89 CALL &ReadSectorWX \ W = SectorLO X = SectorHI
91 <# #S #> TYPE SPACE \ ud -- display the double number
92 SD_BUF $200 DUMP CR ; \ then dump the sector
93 \ ----------------------------------\
96 \ ----------------------------------\
97 CODE FAT \ Display CurFATsector
98 \ ----------------------------------\
101 MOV &CurFATsector,0(PSP) \ FATsectorLO
102 ADD &OrgFAT1,0(PSP) \
103 MOV #0,TOS \ FATsectorHI = 0
104 JMP SECTOR \ jump to a defined word
106 \ ----------------------------------\
109 \ display first sector of a Cluster
110 \ ----------------------------------\
111 CODE CLUSTER \ cluster. -- don't forget to add decimal point to your cluster number
112 \ ----------------------------------\
113 MOV.B &SecPerClus,W \ 3 SecPerClus(5-1) = multiplicator
116 U< IF \ case of SecPerClus>1
118 ADD X,X \ 5 (RLA) shift one left MULTIPLICANDlo16
119 ADDC TOS,TOS \ 1 (RLC) shift one left MULTIPLICANDhi8
120 RRA W \ 1 shift one right multiplicator
121 U>= UNTIL \ carry set
123 ADD &OrgClusters,X \ add OrgClusters = sector of virtual cluster 0 (word size)
125 ADDC #0,TOS \ don't forget carry
126 JMP SECTOR \ jump to a defined word
128 \ ----------------------------------\
131 \ ----------------------------------\
132 CODE DIR \ Display CurrentDir first sector
133 \ ----------------------------------\
135 MOV TOS,2(PSP) \ save TOS
136 MOV &DIRclusterL,0(PSP) \
137 MOV &DIRclusterH,TOS \
140 \ ----------------------------------\
145 ; added : FAT to DUMP first sector of FAT1 and DIR for that of current DIRectory.
146 ; added : SECTOR to DUMP a sector and CLUSTER for first sector of a cluster:
147 ; include a decimal point to force 32 bits number, example : .2 CLUSTER