OSDN Git Service

V309 Modified APPEND" in the long run, clusters can become non-contiguous
[fast-forth/master.git] / MSP430-FORTH / BOOT.f
1
2 ; --------
3 ; BOOT.f
4 ; --------
5 \
6 \ TARGET SELECTION ( = the name of \INC\target.pat file without the extension)
7 \ MSP_EXP430FR5739  MSP_EXP430FR5969    MSP_EXP430FR5994    MSP_EXP430FR6989
8 \ MSP_EXP430FR4133  CHIPSTICK_FR2433    MSP_EXP430FR2433    MSP_EXP430FR2355
9 \ LP_MSP430FR2476
10 \
11 \ from scite editor : copy your target selection in (shift+F8) parameter 1:
12 \
13 \ or, from windows explorer:
14 \ drag and drop this file onto SendSourceFileToTarget.bat
15 \ then select your TARGET when asked.
16 \
17 \ SYSRSTIV decimal/hex values for MSP430FR5994 (device specific)
18 \ ----------------------------------------------------------
19 \ #00 $00 No interrupt pending
20 \ #02 $02 Brownout (BOR)
21 \ #04 $04 RSTIFG RST/NMI (BOR)
22 \ #06 $06 PMMSWBOR software BOR (BOR)
23 \ #08 $08 LPMx.5 wake up (BOR)
24 \ #10 $0A violation memory protected areas (BOR)
25 \ #12 $0C Reserved
26 \ #14 $0E SVSHIFG SVSH event (BOR)
27 \ #16 $10 Reserved
28 \ #18 $12 Reserved
29 \ #20 $14 PMMSWPOR software POR (POR)
30 \ #22 $16 WDTIFG watchdog timeout (PUC)
31 \ #24 $18 WDTPW password violation (PUC)
32 \ #26 $1A FRCTLPW password violation (PUC)
33 \ #28 $1C Uncorrectable FRAM bit error detection (PUC)
34 \ #30 $1E Peripheral area fetch (PUC)
35 \ #32 $20 PMMPW PMM password violation (PUC)
36 \ #34 $22 MPUPW MPU password violation (PUC)
37 \ #36 $24 CSPW CS password violation (PUC)
38 \ #38 $26 MPUSEGIPIFG encapsulated IP memory segment violation (PUC)
39 \ #40 $28 MPUSEGIIFG information memory segment violation (PUC)
40 \ #42 $2A MPUSEG1IFG segment 1 memory violation (PUC)
41 \ #44 $2C MPUSEG2IFG segment 2 memory violation (PUC)
42 \ #46 $2E MPUSEG3IFG segment 3 memory violation (PUC)
43 \
44 \ emulated SYSRSTIV values added by FastForth SYS
45 \ -----------------------------------------------
46 \ n SYS  ( n<0)     : user WIPE = Deep Reset: restores FastForth as it was "flashed"
47 \ -3                : reset after FastForth "flashing".
48 \ SYS               : WARM
49 \ n SYS  (n even )  : user COLD (don't reuse hardware SYSRSTIV!)
50 \ n SYS  (n odd )   : user WARM.
51 \
52 \ note
53 \ ------------------------------------------------------------------------------
54 \ When BOOT.4TH is called by the FastForth bootstrap, the SYSRSTIV (hardware or
55 \ emulated value) is on the Top Of paramater Stack -TOS- ready to test.
56 \ ------------------------------------------------------------------------------
57 \ to enable bootstrap: BOOT
58 \ to disable bootstrap: UNBOOT
59 \ ------------------------------------------------------------------------------
60 \
61 \ it's an example:
62
63 \ https://forth-standard.org/standard/core/DUP
64 \ DUP      x -- x x      duplicate top of stack
65     [UNDEFINED] DUP
66     [IF]
67     CODE DUP
68 BW1 SUB #2,PSP      \ 2  push old TOS..
69     MOV TOS,0(PSP)  \ 3  ..onto stack
70     MOV @IP+,PC     \ 4
71     ENDCODE
72
73 \ https://forth-standard.org/standard/core/qDUP
74 \ ?DUP     x -- 0 | x x    DUP if nonzero
75     CODE ?DUP
76     CMP #0,TOS      \ 2  test for TOS nonzero
77     0<> ?GOTO BW1    \ 2
78     MOV @IP+,PC     \ 4
79     ENDCODE
80     [THEN]
81
82 \ https://forth-standard.org/standard/core/DROP
83 \ DROP     x --          drop top of stack
84     [UNDEFINED] DROP
85     [IF]
86     CODE DROP
87     MOV @PSP+,TOS   \ 2
88     MOV @IP+,PC     \ 4
89     ENDCODE
90     [THEN]
91
92     [UNDEFINED] =
93     [IF]
94 \ https://forth-standard.org/standard/core/Equal
95 \ =      x1 x2 -- flag         test x1=x2
96     CODE =
97     SUB @PSP+,TOS   \ 2
98     SUB #1,TOS      \ 1 borrow (clear cy) if TOS was 0
99     SUBC TOS,TOS    \ 1 TOS=-1 if borrow was set
100     MOV @IP+,PC
101     ENDCODE
102     [THEN]
103
104     [UNDEFINED] +
105     [IF]
106 \ https://forth-standard.org/standard/core/Plus
107 \ +       n1/u1 n2/u2 -- n3/u3     add n1+n2
108     CODE +
109     ADD @PSP+,TOS
110     MOV @IP+,PC
111     ENDCODE
112     [THEN]
113
114     [UNDEFINED] EXECUTE
115     [IF]
116 \ https://forth-standard.org/standard/core/EXECUTE
117 \ EXECUTE   i*x xt -- j*x   execute Forth word at 'xt'
118     CODE EXECUTE
119     PUSH TOS                \ 3 push xt
120     MOV @PSP+,TOS           \ 2
121     MOV @RSP+,PC            \ 4 xt --> PC
122     ENDCODE
123     [THEN]
124
125 \ ------------------------------------------------------------------------------
126 \ WARNING !
127 \ ------------------------------------------------------------------------------
128 \ it is not recommended here to compile then execute a definition
129 \ because the risk of crushing thereafter.
130 \ Interpreting mode as below is required:
131 \ ------------------------------------------------------------------------------
132     DUP 4 =                 \ TOS = SYS value
133     [IF]                    \ if PUC event is <SW1+RESET> or -1 SYS
134         DROP
135         RST_RET             \ remove definitions above
136         LOAD" SD_TEST.4TH"  \ load a file to test the SD_Card driver
137     [ELSE]                  \ else
138         ' SYS $0A + EXECUTE \ return to n SYS to remove definitions above
139     [THEN]                  \ then