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/>.
22 \ https://forth-standard.org/standard/core/HOLDS
23 \ Adds the string represented by addr u to the pictured numeric output string
24 \ compilation use: <# S" string" HOLDS #>
25 \ free HOLDS chars space in the 32+2 bytes HOLD area = {24,21,0} chars with a 32 bits sized {hexa,decimal,binary} number.
26 \ perfect to display all a line on LCD 2x20 chars...
32 BEGIN SUB #1,Y \ 1 dst-1
44 \ https://forth-standard.org/standard/core/StoD
45 \ Convert the number n to the double-cell number d with the same numerical value.
58 \ https://forth-standard.org/standard/core/VALUE
60 \ Skip leading space delimiters. Parse name delimited by a space.
61 \ Create a definition for name with the execution semantics defined below,
62 \ with an initial value equal to x.
64 \ Place x on the stack. The value of x is that given when name was created,
65 \ until the phrase x TO name is executed, causing a new value of x to be assigned to name.
78 \ input: file size double word Sector_per_cluster {1,2,4,8,16,32,64}
79 \ output cluster double word and cluster offset
80 CODE SD_DIV \ SIZ_LO SIZ_HI SECPERCLU -- CLU_LO CLU_HI OFFSET
81 MOV.B 3(PSP),Y \ Y = 0:CurSizeLOHi
82 MOV.B @PSP,X \ X = 0:CurSizeHILo
83 SWPB X \ X = CurSizeHIlo:0
84 ADD Y,X \ X = CurSizeHIlo:CurSizeLOhi
85 MOV.B 1(PSP),Y \ Y:X = CurSize / 256
86 \ RRA Y \ Y = Sectors number_High
87 \ RRC X \ X = Sectors number_Low
89 MOV.B TOS,T \ T = divisor = SECPERCLU
91 MOV #0,W \ 1 W = 0:REMlo = 0
93 \ RRA T \ 1 0>0:SPClo>C preshift one right DIVISOR
99 RRA T \ 1 0>SPChi:SPClo>C
102 RRA W \ 1 0>0:REMlo>C
104 \ 0= UNTIL \ Y = OFFSET, S = CLU_LO, W = CLU_HI
105 S< UNTIL \ Y = OFFSET, S = CLU_LO, W = CLU_HI
106 MOV.B W,TOS \ -- xx xx REMlo
107 MOV X,2(PSP) \ -- CLU_LO xx OFFSET
108 MOV Y,0(PSP) \ -- CLU_LO CLU_HI OFFSET
117 VARIABLE >PAD \ declaration to do in start of source file
118 PAD IS >PAD \ init >PAD, idem
121 \ sample anything during an interrupt for example
122 \ usage in ASSEMBLER WORD : ... LO2HI SAMPLE HI2LO ... if IP is already saved
123 \ usage in ASSEMBLER WORD : ... PUSH IP LO2HI SAMPLE HI2LO MOV @RSP+,IP ... if IP is not already saved
124 \ usage in FORTH WORD : ... SAMPLE ...
127 CMP #TIB,&>PAD \ 4 do nothing if [>PAD] = TIB
129 MOV &>PAD,R6 \ 3 R6 = rDOVAR
130 MOV &TB0R,0(R6) \ 5 we want sample TB0R
133 MOV #R>,R6 \ 2 RFROM ==> rDOVAR
136 ENDCODE \ add LO2HI = 10 + 23 = 33 cycles ==> 4us @ 8MHz
139 \ display samples, up to 42 samples
147 >PAD @ PAD DO \ limit first --
150 PAD IS >PAD \ reset >PAD
159 CODE NOOP \ compile MOV #NEXT,PC
164 CODE SAMPLE. \ display what you want ( much slower than SAMPLE2PAD )
168 MOV &GPFLAGS,TOS \ we want sample GPFLAGS
181 \ ' SAMPLE. IS TEST \ to start test
182 \ ' NOOP IS TEST \ to stop test