Commit 2962f7e6fdcce5076358a15154c09bc8b905dda5
1 parent
98814b45
Outils pour compiler un programme
Showing
7 changed files
with
868 additions
and
1 deletions
Show diff stats
.gitignore
Makefile
@@ -18,14 +18,20 @@ SOURCES=$(wildcard *.asm) $(wildcard *.txt) | @@ -18,14 +18,20 @@ SOURCES=$(wildcard *.asm) $(wildcard *.txt) | ||
18 | 18 | ||
19 | # PROGRAMME | 19 | # PROGRAMME |
20 | 20 | ||
21 | +%.asm: %.txt | ||
22 | + wine scripts/Compilateur.exe scripts/gram.txt "$<" "$@" | ||
23 | + | ||
21 | %.hex: %.asm | 24 | %.hex: %.asm |
22 | scripts/gavrasm "$<" | 25 | scripts/gavrasm "$<" |
23 | 26 | ||
24 | %.upload: %.hex | 27 | %.upload: %.hex |
25 | avrdude -C scripts/avrdude.conf -v -p atmega2560 -c wiring -P /dev/ttyACM0 -b 115200 -D -U flash:w:"$<":i | 28 | avrdude -C scripts/avrdude.conf -v -p atmega2560 -c wiring -P /dev/ttyACM0 -b 115200 -D -U flash:w:"$<":i |
26 | 29 | ||
30 | +%.up: %.upload | ||
31 | + | ||
27 | 32 | ||
28 | clean: | 33 | clean: |
29 | rm -rf $(subst md,html,$(wildcard *.md)) *.tmp | 34 | rm -rf $(subst md,html,$(wildcard *.md)) *.tmp |
30 | rm -rf $(subst md,pdf,$(wildcard *.md)) | 35 | rm -rf $(subst md,pdf,$(wildcard *.md)) |
31 | rm -rf *.hex *.lst | 36 | rm -rf *.hex *.lst |
37 | + |
@@ -0,0 +1,62 @@ | @@ -0,0 +1,62 @@ | ||
1 | +.equ PINA = 0x00 ; définition des adresses des ports | ||
2 | +.equ DDRA = 0x01 | ||
3 | +.equ PORTA = 0x02 | ||
4 | +.equ PINB = 0x03 | ||
5 | +.equ DDRB = 0x04 | ||
6 | +.equ PORTB = 0x05 | ||
7 | + | ||
8 | +.equ RAMEND = 0x21FF | ||
9 | +.equ SPH = 0x3E ; initialisation de la pile | ||
10 | +.equ SPL = 0x3D | ||
11 | + | ||
12 | +.org 0x000 | ||
13 | + ; Vecteur RESET | ||
14 | + jmp debut | ||
15 | + | ||
16 | +.org 0x0080 | ||
17 | + | ||
18 | +debut: | ||
19 | + ldi r16,0xFF ; On configure les ports A et B en sortie | ||
20 | + out DDRA,r16 | ||
21 | + out DDRB,r16 | ||
22 | + r17 <- 0b00000001 ; 8 places de chenillard | ||
23 | + | ||
24 | + | ||
25 | +boucleA: | ||
26 | + ; On affiche l'état courant | ||
27 | + out porta,r17 | ||
28 | + | ||
29 | + call tempo | ||
30 | + | ||
31 | + ; On calcule l'état suivant | ||
32 | + lsl r17 | ||
33 | + si r17 > 0 saut boucleA | ||
34 | + | ||
35 | + ; Si le bit "volant" est sorti de l'octet, on passe à l'autre partie du programme sur le port B | ||
36 | + out porta,r17 ; On éteint le port A | ||
37 | + ; On configure le registre pour qu'il commence de l'autre coté | ||
38 | + r17 <- 0b10000000 | ||
39 | + saut boucleB ; (pas nécessaire) | ||
40 | + | ||
41 | +boucleB: | ||
42 | + out portb,r17 | ||
43 | + | ||
44 | + call tempo; | ||
45 | + | ||
46 | + lsr r17 | ||
47 | + si r17 > 0 saut boucleB | ||
48 | + | ||
49 | + out portb,r17 | ||
50 | + r17 <- 0b00000001 | ||
51 | + saut boucleA | ||
52 | + | ||
53 | +; Programme pour faire une pause | ||
54 | +tempo: | ||
55 | + ; On fait une pause | ||
56 | + ldi r24,8 | ||
57 | +tempoA: | ||
58 | + subi r22,1 | ||
59 | + sbci r23,0 | ||
60 | + sbci r24,0 | ||
61 | + brcc tempoA | ||
62 | + ret |
configure
@@ -26,13 +26,19 @@ fi | @@ -26,13 +26,19 @@ fi | ||
26 | 26 | ||
27 | echo "Vérification des dépendances pour la compilation des programmes Atmega 2560..." | 27 | echo "Vérification des dépendances pour la compilation des programmes Atmega 2560..." |
28 | 28 | ||
29 | +if ! which wine &> /dev/null | ||
30 | +then | ||
31 | + echo "Veuillez installer avrdude (sudo apt-get install wine)" | ||
32 | + exit 1 | ||
33 | +fi | ||
34 | + | ||
29 | if ! which avrdude &> /dev/null | 35 | if ! which avrdude &> /dev/null |
30 | then | 36 | then |
31 | echo "Veuillez installer avrdude (sudo apt-get install avrdude)" | 37 | echo "Veuillez installer avrdude (sudo apt-get install avrdude)" |
32 | exit 1 | 38 | exit 1 |
33 | fi | 39 | fi |
34 | 40 | ||
35 | -echo "Installation des dépendances pour la compilation du compte-rendu..." | 41 | +echo "Installation des bibliothèques pour la compilation du compte-rendu..." |
36 | 42 | ||
37 | echo $(cd scripts; npm install) | 43 | echo $(cd scripts; npm install) |
38 | 44 |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +node_modules |
No preview for this file type
@@ -0,0 +1,791 @@ | @@ -0,0 +1,791 @@ | ||
1 | +% C'est un test | ||
2 | + | ||
3 | +% symbole + : 1 ou plus | ||
4 | +% * : 0 ou plus | ||
5 | +% pour absence de saut de ligne --> | ||
6 | +% {NUMx} pour numérotation | ||
7 | +% {SOURCE}ou {SOURCE-} pour le texte initial | ||
8 | + | ||
9 | +>main | ||
10 | + | ||
11 | +"Aide" | ||
12 | +Bienvenue dans l'outil d'aide au codage | ||
13 | +Traducteur version 1.0, B. CONRARD | ||
14 | +Grammaire du 14/5/14 modifie pour IMA2A | ||
15 | +modifié pour ROUSSEL et SUN | ||
16 | + | ||
17 | +[instruction]:inst | ||
18 | + ; {SOURCE}{inst} | ||
19 | + | ||
20 | +>instruction | ||
21 | + | ||
22 | +[SymboleSi] [blanc]* [Expression]:exp [SymboleAlors] [instruction]:inst | ||
23 | +{exp} TST R16 | ||
24 | + BREQ eti{NUM0} | ||
25 | +{inst}eti{NUM0}: | ||
26 | + | ||
27 | +[SymboleSi] [blanc]* [Expression]:exp [SymboleSaut] [Etiquette]:eti [blanc]* [fin] | ||
28 | +{exp} TST R16 | ||
29 | + BREQ eti{NUM0} | ||
30 | + JMP {eti} | ||
31 | +eti{NUM0}: | ||
32 | + | ||
33 | +[SymboleSi] [blanc]* [Expression]:exp [SymboleAppel] [Etiquette]:eti [blanc]* [fin] | ||
34 | +{exp} TST R16 | ||
35 | + BREQ eti{NUM0} | ||
36 | + CALL {eti} | ||
37 | +eti{NUM0}: | ||
38 | + | ||
39 | +[blanc]* [Registre]:regd [blanc]* [SymboleAffectation] [blanc]* [Registre]:regs [blanc]* [fin] | ||
40 | + MOV {regd},{regs} | ||
41 | + | ||
42 | +[blanc]* [Variable]:var [blanc]* [SymboleAffectation] [blanc]* [Registre]:regs [blanc]* [fin] | ||
43 | + STS {var},{regs} | ||
44 | + | ||
45 | +[blanc]* [Registre]:regd [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* [fin] | ||
46 | +{exp} MOV {regd},R16 | ||
47 | + | ||
48 | +[blanc]* [VariableIO]:var [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* [fin] | ||
49 | +{exp} OUT {var},R16 | ||
50 | + | ||
51 | +[blanc]* [Variable]:var [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* [fin] | ||
52 | +{exp} STS {var},R16 | ||
53 | + | ||
54 | +[SymboleSaut] [Etiquette]:eti [blanc]* [fin] | ||
55 | + JMP {eti} | ||
56 | + | ||
57 | +[SymboleAppel] [Etiquette]:eti [blanc]* [fin] | ||
58 | + CALL {eti} | ||
59 | + | ||
60 | +>2ndeInst | ||
61 | + | ||
62 | +[blanc]* "," [blanc]* [Registre]:regd [blanc]* [SymboleAffectation] [blanc]* [Registre]:regs [blanc]* | ||
63 | + MOV {regd},{regs} | ||
64 | + | ||
65 | +[blanc]* "," [blanc]* [Variable]:var [blanc]* [SymboleAffectation] [blanc]* [Registre]:regs [blanc]* | ||
66 | + STS {var},{regs} | ||
67 | + | ||
68 | +[blanc]* "," [blanc]* [Registre]:regd [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* | ||
69 | +{exp} MOV {regd},R16 | ||
70 | + | ||
71 | +[blanc]* "," [blanc]* [VariableIO]:var [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* | ||
72 | +{exp} OUT {var},R16 | ||
73 | + | ||
74 | +[blanc]* "," [blanc]* [Variable]:var [blanc]* [SymboleAffectation] [blanc]* [Expression]:exp [blanc]* | ||
75 | +{exp} STS {var},R16 | ||
76 | + | ||
77 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
78 | + | ||
79 | +>fin | ||
80 | + | ||
81 | +";" [toutcar]* [finligne] | ||
82 | +--> | ||
83 | + | ||
84 | +[finligne] | ||
85 | +--> | ||
86 | + | ||
87 | +>toutcar | ||
88 | + | ||
89 | +[AlphaNum]:c | ||
90 | +-->{c} | ||
91 | + | ||
92 | +[blanc] | ||
93 | +--> | ||
94 | + | ||
95 | +'<>[]_{}@&~()-çà+éèù%"$£!:;.,?!':c | ||
96 | +-->{c} | ||
97 | + | ||
98 | + | ||
99 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
100 | + | ||
101 | +>Expression | ||
102 | + | ||
103 | +[Expression5]:exp | ||
104 | +-->{exp} | ||
105 | + | ||
106 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
107 | + | ||
108 | +>Expression5 | ||
109 | + | ||
110 | +[Expression25]:exp | ||
111 | +-->{exp} | ||
112 | + | ||
113 | +%%%%%%%%%%%%%%%%%%%%% Operateur OU booleen | ||
114 | + | ||
115 | +>Expression25 | ||
116 | + | ||
117 | +[Expression30]:th [OpExpression25]*:calc | ||
118 | +-->{th}{calc} | ||
119 | + | ||
120 | +>OpExpression25 | ||
121 | + | ||
122 | +[SymboleOuBool] [Expression30]:exp | ||
123 | + TST R16 | ||
124 | + BRNE eti{NUM0} | ||
125 | +{exp}eti{NUM0}: | ||
126 | + | ||
127 | +%%%%%%%%%%%%%%%%%%%%% Operateur ET booleen | ||
128 | + | ||
129 | +>Expression30 | ||
130 | + | ||
131 | +[Expression35]:th [OpExpression30]*:calc | ||
132 | +-->{th}{calc} | ||
133 | + | ||
134 | +>OpExpression30 | ||
135 | + | ||
136 | +[SymboleEtBool] [Expression35]:exp | ||
137 | + TST R16 | ||
138 | + BREQ eti{NUM0} | ||
139 | +{exp}eti{NUM0}: | ||
140 | + | ||
141 | +%%%%%%%%%%%%%%%%%%%%% Comparaison | ||
142 | + | ||
143 | +>Expression35 | ||
144 | + | ||
145 | +[Expression40]:th [OpExpression35]*:calc | ||
146 | +-->{th}{calc} | ||
147 | + | ||
148 | +>OpExpression35 | ||
149 | + | ||
150 | +[SymboleCmp]:symb [Expression45]:exp | ||
151 | + PUSH R16 | ||
152 | +{exp} POP R17 | ||
153 | + CP R17,R16 | ||
154 | + {symb} eti{NUM0} | ||
155 | + CLR R16 | ||
156 | + RJMP eti{NUM1} | ||
157 | +eti{NUM0}: | ||
158 | + LDI R16,0x01 | ||
159 | +eti{NUM1}: | ||
160 | + | ||
161 | +[SymboleCmpSup] [Expression45]:exp | ||
162 | + PUSH R16 | ||
163 | +{exp} POP R17 | ||
164 | + CP R17,R16 | ||
165 | + BREQ eti{NUM0} | ||
166 | + BRLO eti{NUM0} | ||
167 | + LDI R16,0x01 | ||
168 | + RJMP eti{NUM1} | ||
169 | +eti{NUM0}: | ||
170 | + CLR R16 | ||
171 | +eti{NUM1}: | ||
172 | + | ||
173 | +[SymboleCmpInfEgal] [Expression45]:exp | ||
174 | + PUSH R16 | ||
175 | +{exp} POP R17 | ||
176 | + CP R17,R16 | ||
177 | + BREQ eti{NUM0} | ||
178 | + BRLO eti{NUM0} | ||
179 | + CLR R16 | ||
180 | + RJMP eti{NUM1} | ||
181 | +eti{NUM0}: | ||
182 | + LDI R16,0x01 | ||
183 | +eti{NUM1}: | ||
184 | + | ||
185 | +>SymboleCmp | ||
186 | + | ||
187 | +[SymboleCmpEgal] | ||
188 | +-->BREQ | ||
189 | + | ||
190 | +[SymboleCmpDiff] | ||
191 | +-->BRNE | ||
192 | + | ||
193 | +[SymboleCmpInf] | ||
194 | +-->BRLO | ||
195 | + | ||
196 | +[SymboleCmpSupEgal] | ||
197 | +-->BRSH | ||
198 | + | ||
199 | + | ||
200 | +%%%%%%%%%%%%%%%%%%%%% OU Logique | ||
201 | + | ||
202 | +>Expression40 | ||
203 | + | ||
204 | +[Expression45]:th [OpExpression40]*:calc | ||
205 | +-->{th}{calc} | ||
206 | + | ||
207 | +>OpExpression40 | ||
208 | + | ||
209 | +[SymboleOuLogique] [Registre]:reg [Expression45]- | ||
210 | + OR R16,{reg} | ||
211 | + | ||
212 | +[SymboleOuLogique] [Valeur]:val [Expression45]- | ||
213 | + ORI R16,{val} | ||
214 | + | ||
215 | +[SymboleOuLogique] [VariableIO]:var [Expression45]- | ||
216 | + IN R17,{var} | ||
217 | + OR R16,R17 | ||
218 | + | ||
219 | +[SymboleOuLogique] [Tableau]:var [Expression]:exp [blanc]* "]" [Expression45]- | ||
220 | + PUSH R16 | ||
221 | +{exp} LDI R26,low({var}) | ||
222 | + LDI R27,high({var}) | ||
223 | + CLR R17 | ||
224 | + ADD R26,R16 | ||
225 | + ADC R27,R17 | ||
226 | + LD R17,X | ||
227 | + POP R16 | ||
228 | + OR R16,R17 | ||
229 | + | ||
230 | +[SymboleOuLogique] [Variable]:var [Expression45]- | ||
231 | + LDS R17,{var} | ||
232 | + OR R16,R17 | ||
233 | + | ||
234 | +[SymboleOuLogique] [Expression45]:exp | ||
235 | + PUSH R16 | ||
236 | +{exp} POP R17 | ||
237 | + OR R16,R17 | ||
238 | + | ||
239 | +%%%%%%%%%%%%%%%%%%%%% ET Logique | ||
240 | + | ||
241 | +>Expression45 | ||
242 | + | ||
243 | +[Expression50]:th [OpExpression45]*:calc | ||
244 | +-->{th}{calc} | ||
245 | + | ||
246 | +>OpExpression45 | ||
247 | + | ||
248 | +[SymboleEtLogique] [Registre]:reg [OpExpression50]- | ||
249 | + AND R16,{reg} | ||
250 | + | ||
251 | +[SymboleEtLogique] [Valeur]:val [OpExpression50]- | ||
252 | + ANDI R16,{val} | ||
253 | + | ||
254 | +[SymboleEtLogique] [VariableIO]:var [OpExpression50]- | ||
255 | + IN R17,{var} | ||
256 | + AND R16,R17 | ||
257 | + | ||
258 | +[SymboleEtLogique] [Tableau]:var [Expression]:exp [blanc]* "]" [OpExpression50]- | ||
259 | + PUSH R16 | ||
260 | +{exp} LDI R26,low({var}) | ||
261 | + LDI R27,high({var}) | ||
262 | + CLR R17 | ||
263 | + ADD R26,R16 | ||
264 | + ADC R27,R17 | ||
265 | + LD R17,X | ||
266 | + POP R16 | ||
267 | + AND R16,R17 | ||
268 | + | ||
269 | +[SymboleEtLogique] [Variable]:var [OpExpression50]- | ||
270 | + LDS R17,{var} | ||
271 | + AND R16,R17 | ||
272 | + | ||
273 | +[SymboleEtLogique] [Expression50]:exp | ||
274 | + PUSH R16 | ||
275 | +{exp} POP R17 | ||
276 | + AND R16,R17 | ||
277 | + | ||
278 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
279 | + | ||
280 | +>Expression50 | ||
281 | + | ||
282 | +[Expression60]:th [OpExpression50]*:calc | ||
283 | +-->{th}{calc} | ||
284 | + | ||
285 | +>OpExpression50 | ||
286 | + | ||
287 | +[SymboleAddition] [Registre]:reg [OpExpression60]- | ||
288 | + ADD R16,{reg} | ||
289 | + | ||
290 | +[SymboleAddition] [Valeur]:val [OpExpression60]- | ||
291 | + LDI R17,{val} | ||
292 | + ADD R16,R17 | ||
293 | + | ||
294 | +[SymboleAddition] [VariableIO]:var [OpExpression60]- | ||
295 | + IN R17,{var} | ||
296 | + ADD R16,R17 | ||
297 | + | ||
298 | +[SymboleAddition] [Tableau]:var [Expression]:exp [blanc]* "]" [OpExpression60]- | ||
299 | + PUSH R16 | ||
300 | +{exp} LDI R26,low({var}) | ||
301 | + LDI R27,high({var}) | ||
302 | + CLR R17 | ||
303 | + ADD R26,R16 | ||
304 | + ADC R27,R17 | ||
305 | + LD R17,X | ||
306 | + POP R16 | ||
307 | + ADD R16,R17 | ||
308 | + | ||
309 | +[SymboleAddition] [Variable]:var [OpExpression60]- | ||
310 | + LDS R17,{var} | ||
311 | + ADD R16,R17 | ||
312 | + | ||
313 | +[SymboleAddition] [Expression60]:exp | ||
314 | + PUSH R16 | ||
315 | +{exp} POP R17 | ||
316 | + ADD R16,R17 | ||
317 | + | ||
318 | +[SymboleSoustraction] [Registre]:reg [OpExpression60]- | ||
319 | + SUB R16,{reg} | ||
320 | + | ||
321 | +[SymboleSoustraction] [Valeur]:val [OpExpression60]- | ||
322 | + LDI R17,{val} | ||
323 | + SUB R16,R17 | ||
324 | + | ||
325 | +[SymboleSoustraction] [VariableIO]:var [OpExpression60]- | ||
326 | + IN R17,{var} | ||
327 | + SUB R16,R17 | ||
328 | + | ||
329 | +[SymboleSoustraction] [Tableau]:var [Expression]:exp [blanc]* "]" [OpExpression60]- | ||
330 | + PUSH R16 | ||
331 | +{exp} LDI R26,low({var}) | ||
332 | + LDI R27,high({var}) | ||
333 | + CLR R17 | ||
334 | + ADD R26,R16 | ||
335 | + ADC R27,R17 | ||
336 | + LD R17,X | ||
337 | + POP R16 | ||
338 | + SUB R16,R17 | ||
339 | + | ||
340 | +[SymboleSoustraction] [Variable]:var [OpExpression60]- | ||
341 | + LDS R17,{var} | ||
342 | + SUB R16,R17 | ||
343 | + | ||
344 | +[SymboleSoustraction] [Expression60]:exp | ||
345 | + PUSH R16 | ||
346 | +{exp} MOV R17,R16 | ||
347 | + POP R16 | ||
348 | + SUB R16,R17 | ||
349 | + | ||
350 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
351 | + | ||
352 | +>Expression60 | ||
353 | + | ||
354 | +[Expression100]:th [OpExpression60]*:prod | ||
355 | +-->{th}{prod} | ||
356 | + | ||
357 | +>OpExpression60 | ||
358 | + | ||
359 | +[SymboleMultiplier] [Registre]:reg | ||
360 | + MUL R16,{reg} | ||
361 | + MOV R16,R0 | ||
362 | + | ||
363 | +[SymboleMultiplier] [Valeur]:val | ||
364 | + LDI R17,{val} | ||
365 | + MUL R16,R17 | ||
366 | + MOV R16,R0 | ||
367 | + | ||
368 | +[SymboleMultiplier] [VariableIO]:var | ||
369 | + IN R17,{var} | ||
370 | + MUL R16,R17 | ||
371 | + MOV R16,R0 | ||
372 | + | ||
373 | +[SymboleMultiplier] [Tableau]:var [Expression]:exp [blanc]* "]" | ||
374 | + PUSH R16 | ||
375 | +{exp} LDI R26,low({var}) | ||
376 | + LDI R27,high({var}) | ||
377 | + CLR R17 | ||
378 | + ADD R26,R16 | ||
379 | + ADC R27,R17 | ||
380 | + LD R17,X | ||
381 | + POP R16 | ||
382 | + MUL R16,R17 | ||
383 | + MOV R16,R0 | ||
384 | + | ||
385 | +[SymboleMultiplier] [Variable]:var | ||
386 | + LDS R17,{var} | ||
387 | + MUL R16,R17 | ||
388 | + MOV R16,R0 | ||
389 | + | ||
390 | +[SymboleMultiplier] [Expression100]:exp | ||
391 | + PUSH R16 | ||
392 | +{exp} POP R17 | ||
393 | + MUL R16,R17 | ||
394 | + MOV R16,R0 | ||
395 | + | ||
396 | +% diviser | ||
397 | + | ||
398 | +[SymboleDiviser] [Registre]:reg | ||
399 | + MOV R17,{reg} | ||
400 | + SER R18 | ||
401 | +eti{NUM0}: | ||
402 | + INC R18 | ||
403 | + SUB R16,R17 | ||
404 | + BRCC eti{NUM0} | ||
405 | + MOV R16,R18 | ||
406 | + | ||
407 | +[SymboleDiviser] [Valeur]:val | ||
408 | + LDI R17,{val} | ||
409 | + SER R18 | ||
410 | +eti{NUM0}: | ||
411 | + INC R18 | ||
412 | + SUB R16,R17 | ||
413 | + BRCC eti{NUM0} | ||
414 | + MOV R16,R18 | ||
415 | + | ||
416 | +[SymboleDiviser] [VariableIO]:var | ||
417 | + IN R17,{var} | ||
418 | + SER R18 | ||
419 | +eti{NUM0}: | ||
420 | + INC R18 | ||
421 | + SUB R16,R17 | ||
422 | + BRCC eti{NUM0} | ||
423 | + MOV R16,R18 | ||
424 | + | ||
425 | +[SymboleDiviser] [Tableau]:var [Expression]:exp [blanc]* "]" | ||
426 | + PUSH R16 | ||
427 | +{exp} LDI R26,low({var}) | ||
428 | + LDI R27,high({var}) | ||
429 | + CLR R17 | ||
430 | + ADD R26,R16 | ||
431 | + ADC R27,R17 | ||
432 | + LD R17,X | ||
433 | + POP R16 | ||
434 | + SER R18 | ||
435 | +eti{NUM0}: | ||
436 | + INC R18 | ||
437 | + SUB R16,R17 | ||
438 | + BRCC eti{NUM0} | ||
439 | + MOV R16,R18 | ||
440 | + | ||
441 | +[SymboleDiviser] [Variable]:var | ||
442 | + LDS R17,{var} | ||
443 | + SER R18 | ||
444 | +eti{NUM0}: | ||
445 | + INC R18 | ||
446 | + SUB R16,R17 | ||
447 | + BRCC eti{NUM0} | ||
448 | + MOV R16,R18 | ||
449 | + | ||
450 | +[SymboleDiviser] [Expression100]:exp | ||
451 | + PUSH R16 | ||
452 | +{exp} POP R17 | ||
453 | + SER R18 | ||
454 | +eti{NUM0}: | ||
455 | + INC R18 | ||
456 | + SUB R17,R16 | ||
457 | + BRCC eti{NUM0} | ||
458 | + MOV R16,R18 | ||
459 | + | ||
460 | +% Modulo | ||
461 | + | ||
462 | +[SymboleModulo] [Registre]:reg | ||
463 | + MOV R17,{reg} | ||
464 | +eti{NUM0}: | ||
465 | + SUB R16,R17 | ||
466 | + BRCC eti{NUM0} | ||
467 | + | ||
468 | +[SymboleModulo] [Valeur]:val | ||
469 | + LDI R17,{val} | ||
470 | +eti{NUM0}: | ||
471 | + SUB R16,R17 | ||
472 | + BRCC eti{NUM0} | ||
473 | + | ||
474 | +[SymboleModulo] [VariableIO]:var | ||
475 | + IN R17,{var} | ||
476 | +eti{NUM0}: | ||
477 | + SUB R16,R17 | ||
478 | + BRCC eti{NUM0} | ||
479 | + | ||
480 | +[SymboleModulo] [Tableau]:var [Expression]:exp [blanc]* "]" | ||
481 | + PUSH R16 | ||
482 | +{exp} LDI R26,low({var}) | ||
483 | + LDI R27,high({var}) | ||
484 | + CLR R17 | ||
485 | + ADD R26,R16 | ||
486 | + ADC R27,R17 | ||
487 | + LD R17,X | ||
488 | + POP R16 | ||
489 | +eti{NUM0}: | ||
490 | + SUB R16,R17 | ||
491 | + BRCC eti{NUM0} | ||
492 | + | ||
493 | +[SymboleModulo] [Variable]:var | ||
494 | + LDS R17,{var} | ||
495 | +eti{NUM0}: | ||
496 | + SUB R16,R17 | ||
497 | + BRCC eti{NUM0} | ||
498 | + | ||
499 | +[SymboleModulo] [Expression100]:exp | ||
500 | + PUSH R16 | ||
501 | +{exp} MOV R17,R16 | ||
502 | + POP R16 | ||
503 | +eti{NUM0}: | ||
504 | + SUB R16,R17 | ||
505 | + BRCC eti{NUM0} | ||
506 | + | ||
507 | + | ||
508 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
509 | + | ||
510 | +>Expression100 | ||
511 | + | ||
512 | +[Terme]:th | ||
513 | +-->{th} | ||
514 | + | ||
515 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
516 | + | ||
517 | +>Terme | ||
518 | + | ||
519 | +[Registre]:reg | ||
520 | + MOV R16,{reg} | ||
521 | + | ||
522 | +[VariableIO]:var | ||
523 | + IN R16,{var} | ||
524 | + | ||
525 | +[VariableROM]:var | ||
526 | + LDI R30,low({var}<<1) | ||
527 | + LDI R31,high({var}<<1) | ||
528 | + LPM R16,Z | ||
529 | + | ||
530 | +[TableauROM]:var [Expression]:exp [blanc]* "]" | ||
531 | +{exp} LDI R30,low({var}<<1) | ||
532 | + LDI R31,high({var}<<1) | ||
533 | + CLR R17 | ||
534 | + ADD R30,R16 | ||
535 | + ADC R31,R17 | ||
536 | + LPM R16,Z | ||
537 | + | ||
538 | +[Tableau]:var [Expression]:exp [blanc]* "]" | ||
539 | +{exp} LDI R26,low({var}) | ||
540 | + LDI R27,high({var}) | ||
541 | + CLR R17 | ||
542 | + ADD R26,R16 | ||
543 | + ADC R27,R17 | ||
544 | + LD R16,X | ||
545 | + | ||
546 | +[Variable]:var | ||
547 | + LDS R16,{var} | ||
548 | + | ||
549 | +[Valeur]:val | ||
550 | + LDI R16,{val} | ||
551 | + | ||
552 | + | ||
553 | +[blanc]* "(" [Expression]:exp [blanc]* ")" | ||
554 | +-->{exp} | ||
555 | + | ||
556 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%% Variable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
557 | + | ||
558 | +>Registre | ||
559 | + | ||
560 | +[blanc]* 'Rr' '0123456789'+:id | ||
561 | +-->R{id} | ||
562 | + | ||
563 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "@REG" "["- | ||
564 | +-->{l1}{l2} | ||
565 | + | ||
566 | +>VariableIO | ||
567 | + | ||
568 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "@IO" | ||
569 | +-->{l1}{l2} | ||
570 | + | ||
571 | +>VariableROM | ||
572 | + | ||
573 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "@ROM" "["- | ||
574 | +-->{l1}{l2} | ||
575 | + | ||
576 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "@pgm" "["- | ||
577 | +-->{l1}{l2} | ||
578 | + | ||
579 | +>Variable | ||
580 | + | ||
581 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "@"- | ||
582 | +-->{l1}{l2} | ||
583 | + | ||
584 | +>Tableau | ||
585 | + | ||
586 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "[" | ||
587 | +-->{l1}{l2} | ||
588 | + | ||
589 | +>TableauROM | ||
590 | + | ||
591 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "@ROM[" | ||
592 | +-->{l1}{l2} | ||
593 | + | ||
594 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 "@pgm[" | ||
595 | +-->{l1}{l2} | ||
596 | + | ||
597 | +>Valeur | ||
598 | + | ||
599 | +[blanc]* "0b" '01'+:val | ||
600 | +-->0b{val} | ||
601 | + | ||
602 | +[blanc]* "0x" '0123456789abcdefABCDEF'+:val | ||
603 | +-->0x{val} | ||
604 | + | ||
605 | +[blanc]* '0123456789'+:val | ||
606 | +-->{val} | ||
607 | + | ||
608 | +[blanc]* "'" [toutcar]:car "'" | ||
609 | +-->'{car}' | ||
610 | + | ||
611 | +>Etiquette | ||
612 | + | ||
613 | +[blanc]* [Alpha]:l1 [AlphaNum]*:l2 | ||
614 | +-->{l1}{l2} | ||
615 | + | ||
616 | +%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYMBOLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
617 | + | ||
618 | +>SymboleAppel | ||
619 | + | ||
620 | +[blanc]* "appel" | ||
621 | +--> | ||
622 | + | ||
623 | + | ||
624 | +>SymboleSaut | ||
625 | + | ||
626 | +[blanc]* "saut" | ||
627 | +--> | ||
628 | + | ||
629 | +[blanc]* "goto" | ||
630 | +--> | ||
631 | + | ||
632 | +[blanc]* "jump" | ||
633 | +--> | ||
634 | + | ||
635 | +>SymboleSi | ||
636 | + | ||
637 | +[blanc]* "si" | ||
638 | +--> | ||
639 | + | ||
640 | +[blanc]* "if" | ||
641 | +--> | ||
642 | + | ||
643 | +[blanc]* "SI" | ||
644 | +--> | ||
645 | + | ||
646 | +[blanc]* "IF" | ||
647 | +--> | ||
648 | + | ||
649 | +>SymboleAlors | ||
650 | + | ||
651 | +[blanc]* "then" | ||
652 | +--> | ||
653 | + | ||
654 | +[blanc]* "alors" | ||
655 | +--> | ||
656 | + | ||
657 | +[blanc]* "THEN" | ||
658 | +--> | ||
659 | + | ||
660 | +[blanc]* "ALORS" | ||
661 | +--> | ||
662 | + | ||
663 | +>SymboleSeparateur | ||
664 | + | ||
665 | +[blanc]* "," | ||
666 | +--> | ||
667 | + | ||
668 | +>SymboleEtBool | ||
669 | + | ||
670 | +[blanc]* "&&" | ||
671 | +--> | ||
672 | + | ||
673 | +[blanc]* "et" | ||
674 | +--> | ||
675 | + | ||
676 | +>SymboleOuBool | ||
677 | + | ||
678 | +[blanc]* "||" | ||
679 | +--> | ||
680 | + | ||
681 | +[blanc]* "ou" | ||
682 | +--> | ||
683 | + | ||
684 | +>SymboleCmpInf | ||
685 | + | ||
686 | +[blanc]* "<" | ||
687 | +--> | ||
688 | + | ||
689 | +>SymboleCmpInfEgal | ||
690 | + | ||
691 | +[blanc]* "<=" | ||
692 | +--> | ||
693 | + | ||
694 | +>SymboleCmpSup | ||
695 | + | ||
696 | +[blanc]* ">" | ||
697 | +--> | ||
698 | + | ||
699 | +>SymboleCmpSupEgal | ||
700 | + | ||
701 | +[blanc]* ">=" | ||
702 | +--> | ||
703 | + | ||
704 | +>SymboleCmpDiff | ||
705 | + | ||
706 | +[blanc]* "!=" | ||
707 | +--> | ||
708 | + | ||
709 | +[blanc]* "<>" | ||
710 | +--> | ||
711 | + | ||
712 | +>SymboleCmpEgal | ||
713 | + | ||
714 | +[blanc]* "==" | ||
715 | +--> | ||
716 | + | ||
717 | +[blanc]* "=" | ||
718 | +--> | ||
719 | + | ||
720 | +>SymboleEtLogique | ||
721 | + | ||
722 | +[blanc]* "&" | ||
723 | +--> | ||
724 | + | ||
725 | +>SymboleOuLogique | ||
726 | + | ||
727 | +[blanc]* "|" | ||
728 | +--> | ||
729 | + | ||
730 | +>SymboleDiviser | ||
731 | + | ||
732 | +[blanc]* "/" | ||
733 | +--> | ||
734 | + | ||
735 | +>SymboleModulo | ||
736 | + | ||
737 | +[blanc]* "%" | ||
738 | +--> | ||
739 | + | ||
740 | +>SymboleMultiplier | ||
741 | + | ||
742 | +[blanc]* "*" | ||
743 | +--> | ||
744 | + | ||
745 | +>SymboleOuBool | ||
746 | + | ||
747 | +[blanc]* "ou" | ||
748 | +--> | ||
749 | + | ||
750 | +>SymboleAddition | ||
751 | + | ||
752 | +[blanc]* "+" | ||
753 | +--> | ||
754 | + | ||
755 | +>SymboleSoustraction | ||
756 | + | ||
757 | +[blanc]* "-" | ||
758 | +--> | ||
759 | + | ||
760 | +>SymboleAffectation | ||
761 | + | ||
762 | +[blanc]* "<-" | ||
763 | +--> | ||
764 | + | ||
765 | +[blanc]* "=" | ||
766 | +--> | ||
767 | + | ||
768 | +>Alpha | ||
769 | + | ||
770 | +'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_':lettre | ||
771 | +-->{lettre} | ||
772 | + | ||
773 | +>AlphaNum | ||
774 | + | ||
775 | +'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_':lettre | ||
776 | +-->{lettre} | ||
777 | + | ||
778 | +>Num | ||
779 | + | ||
780 | +'0123456789'+:val | ||
781 | +-->{val} | ||
782 | + | ||
783 | +>blanc | ||
784 | + | ||
785 | +" " | ||
786 | +--> | ||
787 | + | ||
788 | +[tabulation] | ||
789 | +--> | ||
790 | + | ||
791 | + |