1 \ -----------------------------------------------------------------------
3 \ -----------------------------------------------------------------------
6 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
7 \ MSP_EXP430FR2433 MSP_EXP430FR4133 CHIPSTICK_FR2433
9 \ MY_MSP430FR5738_1 MY_MSP430FR5738 MY_MSP430FR5948 MY_MSP430FR5948_1
17 \ -----------------------------------------------------------------------
18 \ test CPUx instructions PUSHM, POPM, RLAM, RRAM, RRCM, RRUM
19 \ -----------------------------------------------------------------------
26 \ PUSHM Y,IP \ uncomment to test error (registers bad order)
27 PUSHM IP,W \ PUSHM order : PSP,TOS,IP,S,T,W,X,Y,rEXIT,rDOVAR,rDOCON,rDODOES
28 POPM W,IP \ POPM order : rDODOES,rDOCON,rDOVAR,rEXIT,Y,X,W,T,S,IP,TOS,PSP
30 MOV TOS,8(PSP) \ save old TOS
36 \ RLAM #0,TOS \ uncomment to test error (bad shift value)
37 RRAM #1,TOS \ 0 < shift value < 5
41 COLON \ high level part of the word starts here...
43 ; \ and finishes here.
45 TESTPUSHM ; you should see 11111 3 2 1 0 -->
53 \ PUSHM W,IP \ uncomment to test error "out of bounds"
54 PUSHM IP,W \ PUSHM order : PSP,TOS,IP,S,T,W,X,Y,rEXIT,rDOVAR,rDOCON,rDODOES
55 POPM W,IP \ POPM order : rDODOES,rDOCON,rDOVAR,rEXIT,Y,X,W,T,S,IP,TOS,PSP
57 MOV TOS,8(PSP) \ save old TOS
63 \ RLAM #0,TOS \ uncomment to test error "out of bounds"
64 \ RLAM #5,TOS \ uncomment to test error "out of bounds"
65 RRAM #1,TOS \ 0 < shift value < 5
69 COLON \ high level part of the word starts here...
71 ; \ and finishes here.
73 TESTPOPM ; you should see 11111 3 2 1 0 -->
77 \ -----------------------------------------------------------------------
78 \ test symbolic branch in assembler
79 \ test a FORTH section encapsulated in an assembly word
80 \ -----------------------------------------------------------------------
81 CODE TEST1 \ the word "CODE" add ASSEMBLER as CONTEXT vocabulary...
83 MOV &BASE,&BASE \ to test &xxxx src operand
85 0<> IF MOV #2,&BASE \ if base <> 2
86 ELSE MOV #$0A,&BASE \ else base = 2
88 COLON \ tips : no "ok" displayed in start of line <==> compilation mode
89 BASE @ U. \ always display 10 !
93 \ -----------------------------------------------------------------------
94 \ test a word that starts as word FORTH and ends as assembly word
95 \ -----------------------------------------------------------------------
96 : TEST2 \ ":" starts compilation
97 BASE @ U. \ always display 10 !
98 HI2LO \ switch FORTH to ASM : compile one word (next address)
99 \ add vocabulary ASSEMBLER as CONTEXT vocabulary
100 \ switch in interpret mode
102 0<> IF MOV #2, &BASE \ if variable system BASE <> 2
103 ELSE MOV #10,&BASE \ else (BASE = 2)
105 \ MOV #EXIT,PC \ to pair with ":" i.e. to restore IP saved by : then execute NEXT.
106 \ but even compile two words, it's better to compile an inline EXIT :
107 MOV @RSP+,IP \ restore IP
109 ENDCODE \ ends assembler : remove vocabulary ASSEMBLER from CONTEXT
112 \ -----------------------------------------------------------------------
113 \ test a word that starts as assembly word and ends as FORTH word
114 \ -----------------------------------------------------------------------
115 CODE TEST3 \ "CODE" starts assembler, i.e. add ASSEMBLER as CONTEXT vocabulary
117 0<> IF MOV #2, &BASE \ if variable system BASE <> 2
118 ELSE MOV #10,&BASE \ else (BASE = 2)
120 BASE @ U. \ always display 10 !
125 \ -----------------------------------------------------------------------
126 \ test an assembly jump spanning a section written in FORTH
127 \ -----------------------------------------------------------------------
133 MOV #%1010,TOS \ init count = 10
136 \ IP is already saved by word ":"
137 DUP U. \ display count
140 0= UNTIL MOV @PSP+,TOS
141 \ MOV #EXIT,PC \ to pair with ":" i.e. to restore IP saved by : then execute NEXT.
142 MOV @RSP+,IP \ restore IP
146 TEST5 ; you should see : 9 8 7 6 5 4 3 2 1 0 -->
149 \ -----------------------------------------------------------------------
150 \ tests indexing address
151 \ -----------------------------------------------------------------------
161 8 BYTES_TABLE_IDX BYTES_TABLE \ create table "BYTES_TABLE" with bytes content = 0,1,2,3,4,5,6,7
163 2 BYTES_TABLE C@ . ; you should see 2 -->
167 VARIABLE BYTES_TABLE1
169 $0201 BYTES_TABLE1 ! \ words written in memory are little endian !
171 CODE IDX_TEST1 \ index -- value
172 MOV.B BYTES_TABLE1(TOS),TOS \ -- value
177 0 IDX_TEST1 ; you should see 1 -->
185 1 TEST6 . ; you should see 1 -->
188 \ -----------------------------------------------------------------------
189 \ tests behaviour of assembly error
190 \ -----------------------------------------------------------------------
191 \ R16 causes an error, assembler context is aborted and the word TEST7 is "hidden".
194 \ MOV 0(PSP),0(R16) ; display an error "out of bounds" -->
197 \ -----------------------------------------------------------------------
198 \ tests access to a CREATED word with assembler
199 \ -----------------------------------------------------------------------
228 TABLE 2 - CONSTANT PFA_TABLE \ PFA_TABLE leave the PFA of TABLE
231 CODE REDIRECT ; <table> -- redirects TABLE to argument <table>
238 CODE REDIRECT0 ; -- redirects TABLE to TABLE0
239 MOV #TABLE0,&PFA_TABLE
244 CODE REDIRECT10 ; -- redirects TABLE to TABLE10
245 MOV #TABLE10,&PFA_TABLE
250 CODE REDIRECT20 ; -- redirects TABLE to TABLE20
251 MOV #TABLE20,&PFA_TABLE
263 TABLE0 REDIRECT TABLE 10 DUMP
265 TABLE10 REDIRECT TABLE 10 DUMP
267 TABLE20 REDIRECT TABLE 10 DUMP
270 REDIRECT0 TABLE 10 DUMP
272 REDIRECT10 TABLE 10 DUMP
274 REDIRECT20 TABLE 10 DUMP
277 TABLE0 PFA_TABLE ! TABLE 10 DUMP
279 TABLE10 PFA_TABLE ! TABLE 10 DUMP
281 TABLE20 PFA_TABLE ! TABLE 10 DUMP