1 \ -----------------------------------------------------------------------
3 \ -----------------------------------------------------------------------
6 \ MSP_EXP430FR5739 MSP_EXP430FR5969 MSP_EXP430FR5994 MSP_EXP430FR6989
7 \ MSP_EXP430FR4133 MSP_EXP430FR2433 MSP_EXP430FR2355 CHIPSTICK_FR2433
10 \ -----------------------------------------------------------------------
11 \ test CPUx instructions PUSHM, POPM, RLAM, RRAM, RRCM, RRUM
12 \ -----------------------------------------------------------------------
19 \ PUSHM Y,IP \ uncomment to test error (registers bad order)
20 PUSHM IP,W \ PUSHM order : PSP,TOS,IP,S,T,W,X,Y,rEXIT,rDOVAR,rDOCON,rDODOES
21 POPM W,IP \ POPM order : rDODOES,rDOCON,rDOVAR,rEXIT,Y,X,W,T,S,IP,TOS,PSP
23 MOV TOS,8(PSP) \ save old TOS
29 \ RLAM #0,TOS \ uncomment to test error (bad shift value)
30 RRAM #1,TOS \ 0 < shift value < 5
34 COLON \ high level part of the word starts here...
36 ; \ and finishes here.
38 TESTPUSHM ; you should see 11111 3 2 1 0 -->
46 \ PUSHM W,IP \ uncomment to test error "out of bounds"
47 PUSHM IP,W \ PUSHM order : PSP,TOS,IP,S,T,W,X,Y,rEXIT,rDOVAR,rDOCON,rDODOES
48 POPM W,IP \ POPM order : rDODOES,rDOCON,rDOVAR,rEXIT,Y,X,W,T,S,IP,TOS,PSP
50 MOV TOS,8(PSP) \ save old TOS
56 \ RLAM #0,TOS \ uncomment to test error "out of bounds"
57 \ RLAM #5,TOS \ uncomment to test error "out of bounds"
58 RRAM #1,TOS \ 0 < shift value < 5
62 COLON \ high level part of the word starts here...
64 ; \ and finishes here.
66 TESTPOPM ; you should see 11111 3 2 1 0 -->
70 \ -----------------------------------------------------------------------
71 \ test symbolic branch in assembler
72 \ test a FORTH section encapsulated in an assembly word
73 \ -----------------------------------------------------------------------
74 CODE TEST1 \ the word "CODE" add ASSEMBLER as CONTEXT vocabulary...
76 MOV &BASE,&BASE \ to test &xxxx src operand
78 0<> IF MOV #2,&BASE \ if base <> 2
79 ELSE MOV #$0A,&BASE \ else base = 2
81 COLON \ tips : no "ok" displayed in start of line <==> compilation mode
82 BASE @ U. \ always display 10 !
86 \ -----------------------------------------------------------------------
87 \ test a word that starts as word FORTH and ends as assembly word
88 \ -----------------------------------------------------------------------
89 : TEST2 \ ":" starts compilation
90 BASE @ U. \ always display 10 !
91 HI2LO \ switch FORTH to ASM : compile one word (next address)
92 \ add vocabulary ASSEMBLER as CONTEXT vocabulary
93 \ switch in interpret mode
95 0<> IF MOV #2, &BASE \ if variable system BASE <> 2
96 ELSE MOV #10,&BASE \ else (BASE = 2)
98 \ MOV #EXIT,PC \ to pair with ":" i.e. to restore IP saved by : then execute NEXT.
99 \ but even compile two words, it's better to compile an inline EXIT :
100 MOV @RSP+,IP \ restore IP
102 ENDCODE \ ends assembler : remove vocabulary ASSEMBLER from CONTEXT
105 \ -----------------------------------------------------------------------
106 \ test a word that starts as assembly word and ends as FORTH word
107 \ -----------------------------------------------------------------------
108 CODE TEST3 \ "CODE" starts assembler, i.e. add ASSEMBLER as CONTEXT vocabulary
110 0<> IF MOV #2, &BASE \ if variable system BASE <> 2
111 ELSE MOV #10,&BASE \ else (BASE = 2)
113 BASE @ U. \ always display 10 !
118 \ -----------------------------------------------------------------------
119 \ test an assembly jump spanning a section written in FORTH
120 \ -----------------------------------------------------------------------
126 MOV #%1010,TOS \ init count = 10
129 \ IP is already saved by word ":"
130 DUP U. \ display count
133 0= UNTIL MOV @PSP+,TOS
134 \ MOV #EXIT,PC \ to pair with ":" i.e. to restore IP saved by : then execute NEXT.
135 MOV @RSP+,IP \ restore IP
139 TEST5 ; you should see : 9 8 7 6 5 4 3 2 1 0 -->
142 \ -----------------------------------------------------------------------
143 \ tests indexing address
144 \ -----------------------------------------------------------------------
154 8 BYTES_TABLE_IDX BYTES_TABLE \ create table "BYTES_TABLE" with bytes content = 0,1,2,3,4,5,6,7
156 2 BYTES_TABLE C@ . ; you should see 2 -->
160 VARIABLE BYTES_TABLE1
162 $0201 BYTES_TABLE1 ! \ words written in memory are little endian !
164 CODE IDX_TEST1 \ index -- value
165 MOV.B BYTES_TABLE1(TOS),TOS \ -- value
170 0 IDX_TEST1 ; you should see 1 -->
178 1 TEST6 . ; you should see 1 -->
181 \ -----------------------------------------------------------------------
182 \ tests behaviour of assembly error
183 \ -----------------------------------------------------------------------
184 \ R16 causes an error, assembler context is aborted and the word TEST7 is "hidden".
187 \ MOV 0(PSP),0(R16) ; display an error "out of bounds" -->
190 \ -----------------------------------------------------------------------
191 \ tests access to a CREATED word with assembler
192 \ -----------------------------------------------------------------------
221 TABLE 2 - CONSTANT PFA_TABLE \ PFA_TABLE leave the PFA of TABLE
224 CODE REDIRECT ; <table> -- redirects TABLE to argument <table>
231 CODE REDIRECT0 ; -- redirects TABLE to TABLE0
232 MOV #TABLE0,&PFA_TABLE
237 CODE REDIRECT10 ; -- redirects TABLE to TABLE10
238 MOV #TABLE10,&PFA_TABLE
243 CODE REDIRECT20 ; -- redirects TABLE to TABLE20
244 MOV #TABLE20,&PFA_TABLE
256 TABLE0 REDIRECT TABLE 10 DUMP
258 TABLE10 REDIRECT TABLE 10 DUMP
260 TABLE20 REDIRECT TABLE 10 DUMP
263 REDIRECT0 TABLE 10 DUMP
265 REDIRECT10 TABLE 10 DUMP
267 REDIRECT20 TABLE 10 DUMP
270 TABLE0 PFA_TABLE ! TABLE 10 DUMP
272 TABLE10 PFA_TABLE ! TABLE 10 DUMP
274 TABLE20 PFA_TABLE ! TABLE 10 DUMP