Repare & et |
This commit is contained in:
Executable
BIN
Binary file not shown.
@@ -0,0 +1,23 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$a
|
||||||
|
lw $t0, $$a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
procedure
|
||||||
|
<l_instr>
|
||||||
|
<instr_retour>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_retour>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
procedure
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
procedure id_fonction procedure
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
retour mot_clef retour
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
procedure id_fonction procedure
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
procedure :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 4($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
jal procedure
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>procedure</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionRetour>
|
||||||
|
<mot_clef>retour</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionRetour>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>procedure</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 1
|
||||||
|
sommet = 1
|
||||||
|
0 procedure GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 procedure GLOBALE FONCTION 0 0
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 40
|
||||||
|
$$b: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 10
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t4, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$a($t4)
|
||||||
|
li $t0, 5
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$b
|
||||||
|
Indice tableau $a est attendu
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
procedure
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_appel>
|
||||||
|
<appel>
|
||||||
|
procedure
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</instr_appel>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
procedure id_fonction procedure
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
procedure id_fonction procedure
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
procedure :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 4 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
jal procedure
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>procedure</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAppel>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>procedure</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAppel>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 1
|
||||||
|
sommet = 2
|
||||||
|
0 procedure GLOBALE FONCTION 0 0
|
||||||
|
1 $a LOCALE ENTIER 0 -1
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 procedure GLOBALE FONCTION 0 0
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
Fonction main non trouvé
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_si>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</instr_si>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
si mot_clef si
|
||||||
|
1 nombre 1
|
||||||
|
alors mot_clef alors
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
1 nombre 1
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $zero e0
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
j e1
|
||||||
|
e0:
|
||||||
|
e1:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionSi>
|
||||||
|
<mot_clef>si</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>alors</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
<optSinon>
|
||||||
|
</optSinon>
|
||||||
|
</instructionSi>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_si>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</instr_si>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
si mot_clef si
|
||||||
|
0 nombre 0
|
||||||
|
alors mot_clef alors
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
1 nombre 1
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
sinon mot_clef sinon
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
0 nombre 0
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $zero e0
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
j e1
|
||||||
|
e0:
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
e1:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionSi>
|
||||||
|
<mot_clef>si</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>alors</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
<optSinon>
|
||||||
|
<mot_clef>sinon</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</optSinon>
|
||||||
|
</instructionSi>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<tabDec>$tab[10]</tabDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_tantque>
|
||||||
|
<opExp>
|
||||||
|
inf
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>10</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_indicee>
|
||||||
|
<var_base_tableau>$tab</var_base_tableau>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</var_indicee>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</instr_tantque>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_tantque>
|
||||||
|
<opExp>
|
||||||
|
inf
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>10</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<varExp>
|
||||||
|
<var_indicee>
|
||||||
|
<var_base_tableau>$tab</var_base_tableau>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</var_indicee>
|
||||||
|
</varExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</instr_tantque>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$tab id_variable $tab
|
||||||
|
[ symbole CROCHET_OUVRANT
|
||||||
|
10 nombre 10
|
||||||
|
] symbole CROCHET_FERMANT
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
0 nombre 0
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
tantque mot_clef tantque
|
||||||
|
$a id_variable $a
|
||||||
|
< symbole INFERIEUR
|
||||||
|
10 nombre 10
|
||||||
|
faire mot_clef faire
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$tab id_variable $tab
|
||||||
|
[ symbole CROCHET_OUVRANT
|
||||||
|
$a id_variable $a
|
||||||
|
] symbole CROCHET_FERMANT
|
||||||
|
= symbole EGAL
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
$a id_variable $a
|
||||||
|
+ symbole PLUS
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
0 nombre 0
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
tantque mot_clef tantque
|
||||||
|
$a id_variable $a
|
||||||
|
< symbole INFERIEUR
|
||||||
|
10 nombre 10
|
||||||
|
faire mot_clef faire
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$tab id_variable $tab
|
||||||
|
[ symbole CROCHET_OUVRANT
|
||||||
|
$a id_variable $a
|
||||||
|
] symbole CROCHET_FERMANT
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
$a id_variable $a
|
||||||
|
+ symbole PLUS
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
.data
|
||||||
|
$$tab: .space 40
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
e0:
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 10
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
blt $t1, $t2 e2
|
||||||
|
li $t0, 0
|
||||||
|
e2:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $0 e1
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t4, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$tab($t4)
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
j e0
|
||||||
|
e1:
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
e3:
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 10
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
blt $t1, $t2 e5
|
||||||
|
li $t0, 0
|
||||||
|
e5:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $0 e4
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t4, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
lw $t0, $$tab($t4)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
j e3
|
||||||
|
e4:
|
||||||
|
addi $sp, $sp 4 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,487 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$tab</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
<symbole>CROCHET_OUVRANT</symbole>
|
||||||
|
<nombre>10</nombre>
|
||||||
|
<symbole>CROCHET_FERMANT</symbole>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionTantque>
|
||||||
|
<mot_clef>tantque</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>INFERIEUR</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>10</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>faire</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$tab</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
<symbole>CROCHET_OUVRANT</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>CROCHET_FERMANT</symbole>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</instructionTantque>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionTantque>
|
||||||
|
<mot_clef>tantque</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>INFERIEUR</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>10</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>faire</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$tab</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
<symbole>CROCHET_OUVRANT</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>CROCHET_FERMANT</symbole>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</instructionTantque>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 3
|
||||||
|
0 $tab GLOBALE TABLEAU 0 10
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
2 $a LOCALE ENTIER 0 -1
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<tabDec>$tab[10]</tabDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_indicee>
|
||||||
|
<var_base_tableau>$tab</var_base_tableau>
|
||||||
|
<intExp>4</intExp>
|
||||||
|
</var_indicee>
|
||||||
|
<intExp>4</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<varExp>
|
||||||
|
<var_indicee>
|
||||||
|
<var_base_tableau>$tab</var_base_tableau>
|
||||||
|
<intExp>4</intExp>
|
||||||
|
</var_indicee>
|
||||||
|
</varExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$tab id_variable $tab
|
||||||
|
[ symbole CROCHET_OUVRANT
|
||||||
|
10 nombre 10
|
||||||
|
] symbole CROCHET_FERMANT
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$tab id_variable $tab
|
||||||
|
[ symbole CROCHET_OUVRANT
|
||||||
|
4 nombre 4
|
||||||
|
] symbole CROCHET_FERMANT
|
||||||
|
= symbole EGAL
|
||||||
|
4 nombre 4
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$tab id_variable $tab
|
||||||
|
[ symbole CROCHET_OUVRANT
|
||||||
|
4 nombre 4
|
||||||
|
] symbole CROCHET_FERMANT
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
.data
|
||||||
|
$$tab: .space 40
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t4, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$tab($t4)
|
||||||
|
li $t0, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t4, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
add $t4,$t4,$t4
|
||||||
|
lw $t0, $$tab($t4)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$tab</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
<symbole>CROCHET_OUVRANT</symbole>
|
||||||
|
<nombre>10</nombre>
|
||||||
|
<symbole>CROCHET_FERMANT</symbole>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$tab</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
<symbole>CROCHET_OUVRANT</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>4</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>CROCHET_FERMANT</symbole>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>4</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$tab</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
<symbole>CROCHET_OUVRANT</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>4</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>CROCHET_FERMANT</symbole>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 $tab GLOBALE TABLEAU 0 10
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_tantque>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</instr_tantque>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
tantque mot_clef tantque
|
||||||
|
0 nombre 0
|
||||||
|
faire mot_clef faire
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
1 nombre 1
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
e0:
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $0 e1
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
j e0
|
||||||
|
e1:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionTantque>
|
||||||
|
<mot_clef>tantque</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>faire</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</instructionTantque>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_tantque>
|
||||||
|
<opExp>
|
||||||
|
inf
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>10</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</instr_tantque>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
0 nombre 0
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
tantque mot_clef tantque
|
||||||
|
$a id_variable $a
|
||||||
|
< symbole INFERIEUR
|
||||||
|
10 nombre 10
|
||||||
|
faire mot_clef faire
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
$a id_variable $a
|
||||||
|
+ symbole PLUS
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$a
|
||||||
|
e0:
|
||||||
|
lw $t0, $$a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 10
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
blt $t1, $t2 e2
|
||||||
|
li $t0, 0
|
||||||
|
e2:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $0 e1
|
||||||
|
lw $t0, $$a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
lw $t0, $$a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$a
|
||||||
|
j e0
|
||||||
|
e1:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionTantque>
|
||||||
|
<mot_clef>tantque</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>INFERIEUR</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>10</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>faire</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</instructionTantque>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$t0</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$t1</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$123</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$$</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$$$</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$f</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$_</varDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
f
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$$</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$$$</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$f</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$_</varDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$</var_simple>
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$123</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$_</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</opExp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$$</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$t0</var_simple>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$123</var_simple>
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$t0</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_appel>
|
||||||
|
<appel>
|
||||||
|
f
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$123</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</instr_appel>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$t0 id_variable $t0
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$t1 id_variable $t1
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$123 id_variable $123
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$ id_variable $
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$$ id_variable $$
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$$$ id_variable $$$
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$f id_variable $f
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$_ id_variable $_
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
f id_fonction f
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$$ id_variable $$
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$$$ id_variable $$$
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$f id_variable $f
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$_ id_variable $_
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$ id_variable $
|
||||||
|
= symbole EGAL
|
||||||
|
$123 id_variable $123
|
||||||
|
+ symbole PLUS
|
||||||
|
$_ id_variable $_
|
||||||
|
+ symbole PLUS
|
||||||
|
$$ id_variable $$
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$ id_variable $
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$t0 id_variable $t0
|
||||||
|
= symbole EGAL
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
$123 id_variable $123
|
||||||
|
= symbole EGAL
|
||||||
|
$t0 id_variable $t0
|
||||||
|
+ symbole PLUS
|
||||||
|
0 nombre 0
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
f id_fonction f
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$123 id_variable $123
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
.data
|
||||||
|
$$t0: .space 4
|
||||||
|
$$t1: .space 4
|
||||||
|
$$123: .space 4
|
||||||
|
$$: .space 4
|
||||||
|
$$$: .space 4
|
||||||
|
$$$$: .space 4
|
||||||
|
$$f: .space 4
|
||||||
|
$$_: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
f :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
lw $t0, $$123
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, -16($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 4($fp) #variable argument $$
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$
|
||||||
|
lw $t0, $$
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 12 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$t0
|
||||||
|
lw $t0, $$t0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$123
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, $$123
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal f
|
||||||
|
addi $sp, $sp, 4 #désalocation des arguments
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,401 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$t0</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$t1</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$123</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$$</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$$$</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$f</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$_</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>f</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$$</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$$$</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$f</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$_</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$123</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$_</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$$</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$t0</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$123</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$t0</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAppel>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>f</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$123</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAppel>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 9
|
||||||
|
sommet = 13
|
||||||
|
0 $t0 GLOBALE ENTIER 0 -1
|
||||||
|
1 $t1 GLOBALE ENTIER 4 -1
|
||||||
|
2 $123 GLOBALE ENTIER 8 -1
|
||||||
|
3 $ GLOBALE ENTIER 12 -1
|
||||||
|
4 $$ GLOBALE ENTIER 16 -1
|
||||||
|
5 $$$ GLOBALE ENTIER 20 -1
|
||||||
|
6 $f GLOBALE ENTIER 24 -1
|
||||||
|
7 $_ GLOBALE ENTIER 28 -1
|
||||||
|
8 f GLOBALE FONCTION 0 1
|
||||||
|
9 $$ ARGUMENT ENTIER 0 -1
|
||||||
|
10 $$$ LOCALE ENTIER 0 -1
|
||||||
|
11 $f LOCALE ENTIER 4 -1
|
||||||
|
12 $_ LOCALE ENTIER 8 -1
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
base = 10
|
||||||
|
sommet = 10
|
||||||
|
0 $t0 GLOBALE ENTIER 0 -1
|
||||||
|
1 $t1 GLOBALE ENTIER 4 -1
|
||||||
|
2 $123 GLOBALE ENTIER 8 -1
|
||||||
|
3 $ GLOBALE ENTIER 12 -1
|
||||||
|
4 $$ GLOBALE ENTIER 16 -1
|
||||||
|
5 $$$ GLOBALE ENTIER 20 -1
|
||||||
|
6 $f GLOBALE ENTIER 24 -1
|
||||||
|
7 $_ GLOBALE ENTIER 28 -1
|
||||||
|
8 f GLOBALE FONCTION 0 1
|
||||||
|
9 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
et
|
||||||
|
<intExp>1</intExp>
|
||||||
|
<intExp>2</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
1 nombre 1
|
||||||
|
& symbole ET
|
||||||
|
2 nombre 2
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e1
|
||||||
|
li $t0, 2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t2, e1
|
||||||
|
and $t0, $t1, $t2
|
||||||
|
j e0
|
||||||
|
e1 :
|
||||||
|
li $t0 0
|
||||||
|
e0 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
<symbole>ET</symbole>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>2</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 1
|
||||||
|
sommet = 1
|
||||||
|
0 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
add :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
lw $t0, 8($fp) #variable argument $a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 4($fp) #variable argument $b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 12($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
li $t0, 2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -12($fp) #variable locale
|
||||||
|
li $t0, 3
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -16($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, -12($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, -16($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
Nombre Argument différent pour l'appel à add
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$i</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$carre</varDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$i</var_simple>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_tantque>
|
||||||
|
<opExp>
|
||||||
|
inf
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$i</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>10</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$carre</var_simple>
|
||||||
|
<opExp>
|
||||||
|
fois
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$i</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$i</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$carre</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$i</var_simple>
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$i</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</instr_tantque>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$i id_variable $i
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$carre id_variable $carre
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$i id_variable $i
|
||||||
|
= symbole EGAL
|
||||||
|
0 nombre 0
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
tantque mot_clef tantque
|
||||||
|
$i id_variable $i
|
||||||
|
< symbole INFERIEUR
|
||||||
|
10 nombre 10
|
||||||
|
faire mot_clef faire
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$carre id_variable $carre
|
||||||
|
= symbole EGAL
|
||||||
|
$i id_variable $i
|
||||||
|
* symbole FOIS
|
||||||
|
$i id_variable $i
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$carre id_variable $carre
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
$i id_variable $i
|
||||||
|
= symbole EGAL
|
||||||
|
$i id_variable $i
|
||||||
|
+ symbole PLUS
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
.data
|
||||||
|
$$i: .space 4
|
||||||
|
$$carre: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$i
|
||||||
|
e0:
|
||||||
|
lw $t0, $$i
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 10
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
blt $t1, $t2 e2
|
||||||
|
li $t0, 0
|
||||||
|
e2:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $0 e1
|
||||||
|
lw $t0, $$i
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, $$i
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
mult $t1, $t2
|
||||||
|
mflo $t0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$carre
|
||||||
|
lw $t0, $$carre
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
lw $t0, $$i
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$i
|
||||||
|
j e0
|
||||||
|
e1:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,283 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$i</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$carre</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$i</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionTantque>
|
||||||
|
<mot_clef>tantque</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$i</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>INFERIEUR</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>10</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>faire</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$carre</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$i</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
<symbole>FOIS</symbole>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$i</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$carre</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$i</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$i</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</instructionTantque>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 3
|
||||||
|
sommet = 3
|
||||||
|
0 $i GLOBALE ENTIER 0 -1
|
||||||
|
1 $carre GLOBALE ENTIER 4 -1
|
||||||
|
2 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
fact
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$f</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_instr>
|
||||||
|
<instr_si>
|
||||||
|
<opExp>
|
||||||
|
ou
|
||||||
|
<opExp>
|
||||||
|
egal
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$f</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</opExp>
|
||||||
|
<opExp>
|
||||||
|
egal
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$f</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</opExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_retour>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_retour>
|
||||||
|
</l_instr>
|
||||||
|
<l_instr>
|
||||||
|
<instr_retour>
|
||||||
|
<opExp>
|
||||||
|
fois
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
fact
|
||||||
|
<l_exp>
|
||||||
|
<opExp>
|
||||||
|
moins
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$f</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$f</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_retour>
|
||||||
|
</l_instr>
|
||||||
|
</instr_si>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
fact
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
fact id_fonction fact
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$f id_variable $f
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
si mot_clef si
|
||||||
|
$f id_variable $f
|
||||||
|
= symbole EGAL
|
||||||
|
1 nombre 1
|
||||||
|
| symbole OU
|
||||||
|
$f id_variable $f
|
||||||
|
= symbole EGAL
|
||||||
|
0 nombre 0
|
||||||
|
alors mot_clef alors
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
retour mot_clef retour
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
sinon mot_clef sinon
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
retour mot_clef retour
|
||||||
|
fact id_fonction fact
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$f id_variable $f
|
||||||
|
- symbole MOINS
|
||||||
|
1 nombre 1
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
* symbole FOIS
|
||||||
|
$f id_variable $f
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
fact id_fonction fact
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
fact :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
lw $t0, 4($fp) #variable argument $f
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
beq $t1, $t2 e4
|
||||||
|
li $t0, 0
|
||||||
|
e4:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e0
|
||||||
|
j e2
|
||||||
|
e0 :
|
||||||
|
lw $t0, 4($fp) #variable argument $f
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
beq $t1, $t2 e5
|
||||||
|
li $t0, 0
|
||||||
|
e5:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
e2 :
|
||||||
|
or $t0, $t1, $t2
|
||||||
|
j e3
|
||||||
|
e1 :
|
||||||
|
or $t0, $t1, $t2
|
||||||
|
e3 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $zero e6
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 8($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
j e7
|
||||||
|
e6:
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, 4($fp) #variable argument $f
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sub $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal fact
|
||||||
|
addi $sp, $sp, 4 #désalocation des arguments
|
||||||
|
lw $t0, 4($fp) #variable argument $f
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
mult $t1, $t2
|
||||||
|
mflo $t0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 8($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
e7:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal fact
|
||||||
|
addi $sp, $sp, 4 #désalocation des arguments
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 4 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,408 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>fact</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$f</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionSi>
|
||||||
|
<mot_clef>si</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$f</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
<symbole>OU</symbole>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$f</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>alors</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionRetour>
|
||||||
|
<mot_clef>retour</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionRetour>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
<optSinon>
|
||||||
|
<mot_clef>sinon</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionRetour>
|
||||||
|
<mot_clef>retour</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>fact</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$f</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>MOINS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
<symbole>FOIS</symbole>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$f</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionRetour>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</optSinon>
|
||||||
|
</instructionSi>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>fact</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 1
|
||||||
|
sommet = 2
|
||||||
|
0 fact GLOBALE FONCTION 0 1
|
||||||
|
1 $f ARGUMENT ENTIER 0 -1
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 3
|
||||||
|
0 fact GLOBALE FONCTION 0 1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
2 $a LOCALE ENTIER 0 -1
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
fibo
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$n</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_instr>
|
||||||
|
<instr_si>
|
||||||
|
<opExp>
|
||||||
|
inf
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$n</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>2</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_retour>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</instr_retour>
|
||||||
|
</l_instr>
|
||||||
|
<l_instr>
|
||||||
|
<instr_retour>
|
||||||
|
<opExp>
|
||||||
|
plus
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
fibo
|
||||||
|
<l_exp>
|
||||||
|
<opExp>
|
||||||
|
moins
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$n</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>1</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
fibo
|
||||||
|
<l_exp>
|
||||||
|
<opExp>
|
||||||
|
moins
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$n</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>2</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_retour>
|
||||||
|
</l_instr>
|
||||||
|
</instr_si>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
fibo
|
||||||
|
<l_exp>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
fibo id_fonction fibo
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$n id_variable $n
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
si mot_clef si
|
||||||
|
$n id_variable $n
|
||||||
|
< symbole INFERIEUR
|
||||||
|
2 nombre 2
|
||||||
|
alors mot_clef alors
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
retour mot_clef retour
|
||||||
|
1 nombre 1
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
sinon mot_clef sinon
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
retour mot_clef retour
|
||||||
|
fibo id_fonction fibo
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$n id_variable $n
|
||||||
|
- symbole MOINS
|
||||||
|
1 nombre 1
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
+ symbole PLUS
|
||||||
|
fibo id_fonction fibo
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$n id_variable $n
|
||||||
|
- symbole MOINS
|
||||||
|
2 nombre 2
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
fibo id_fonction fibo
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
fibo :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
lw $t0, 4($fp) #variable argument $n
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
blt $t1, $t2 e0
|
||||||
|
li $t0, 0
|
||||||
|
e0:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $zero e1
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 8($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
j e2
|
||||||
|
e1:
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, 4($fp) #variable argument $n
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sub $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal fibo
|
||||||
|
addi $sp, $sp, 4 #désalocation des arguments
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, 4($fp) #variable argument $n
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sub $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal fibo
|
||||||
|
addi $sp, $sp, 4 #désalocation des arguments
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
add $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 8($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
e2:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal fibo
|
||||||
|
addi $sp, $sp, 4 #désalocation des arguments
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,360 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>fibo</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$n</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionSi>
|
||||||
|
<mot_clef>si</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$n</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>INFERIEUR</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>2</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>alors</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionRetour>
|
||||||
|
<mot_clef>retour</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionRetour>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
<optSinon>
|
||||||
|
<mot_clef>sinon</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionRetour>
|
||||||
|
<mot_clef>retour</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>fibo</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$n</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>MOINS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>PLUS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>fibo</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$n</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>MOINS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>2</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionRetour>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</optSinon>
|
||||||
|
</instructionSi>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>fibo</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 1
|
||||||
|
sommet = 2
|
||||||
|
0 fibo GLOBALE FONCTION 0 1
|
||||||
|
1 $n ARGUMENT ENTIER 0 -1
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 fibo GLOBALE FONCTION 0 1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$b</varDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
pgcd
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$b</varDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$c</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$c</var_simple>
|
||||||
|
<opExp>
|
||||||
|
moins
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<opExp>
|
||||||
|
fois
|
||||||
|
<opExp>
|
||||||
|
divise
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</opExp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</opExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_si>
|
||||||
|
<opExp>
|
||||||
|
egal
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$c</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<intExp>0</intExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_retour>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</instr_retour>
|
||||||
|
</l_instr>
|
||||||
|
<l_instr>
|
||||||
|
<instr_retour>
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
pgcd
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$c</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
</instr_retour>
|
||||||
|
</l_instr>
|
||||||
|
</instr_si>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_affect>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</instr_affect>
|
||||||
|
<l_instr>
|
||||||
|
<instr_si>
|
||||||
|
<opExp>
|
||||||
|
inf
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
pgcd
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<appelExp>
|
||||||
|
<appel>
|
||||||
|
pgcd
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$b</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
<varExp>
|
||||||
|
<var_simple>$a</var_simple>
|
||||||
|
</varExp>
|
||||||
|
<l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</l_exp>
|
||||||
|
</appel>
|
||||||
|
</appelExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</instr_si>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$b id_variable $b
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
pgcd id_fonction pgcd
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
, symbole VIRGULE
|
||||||
|
entier mot_clef entier
|
||||||
|
$b id_variable $b
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
entier mot_clef entier
|
||||||
|
$c id_variable $c
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$c id_variable $c
|
||||||
|
= symbole EGAL
|
||||||
|
$a id_variable $a
|
||||||
|
- symbole MOINS
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
/ symbole DIVISE
|
||||||
|
$b id_variable $b
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
* symbole FOIS
|
||||||
|
$b id_variable $b
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
si mot_clef si
|
||||||
|
$c id_variable $c
|
||||||
|
= symbole EGAL
|
||||||
|
0 nombre 0
|
||||||
|
alors mot_clef alors
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
retour mot_clef retour
|
||||||
|
$b id_variable $b
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
sinon mot_clef sinon
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
retour mot_clef retour
|
||||||
|
pgcd id_fonction pgcd
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$b id_variable $b
|
||||||
|
, symbole VIRGULE
|
||||||
|
$c id_variable $c
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
= symbole EGAL
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
$b id_variable $b
|
||||||
|
= symbole EGAL
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
si mot_clef si
|
||||||
|
$b id_variable $b
|
||||||
|
< symbole INFERIEUR
|
||||||
|
$a id_variable $a
|
||||||
|
alors mot_clef alors
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
pgcd id_fonction pgcd
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$a id_variable $a
|
||||||
|
, symbole VIRGULE
|
||||||
|
$b id_variable $b
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
sinon mot_clef sinon
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
pgcd id_fonction pgcd
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
$b id_variable $b
|
||||||
|
, symbole VIRGULE
|
||||||
|
$a id_variable $a
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 4
|
||||||
|
$$b: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
pgcd :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
lw $t0, 8($fp) #variable argument $a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 8($fp) #variable argument $a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 4($fp) #variable argument $b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
div $t1, $t2
|
||||||
|
mflo $t0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 4($fp) #variable argument $b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
mult $t1, $t2
|
||||||
|
mflo $t0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sub $t0, $t1, $t2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, -8($fp) #variable locale
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
beq $t1, $t2 e0
|
||||||
|
li $t0, 0
|
||||||
|
e0:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $zero e1
|
||||||
|
lw $t0, 4($fp) #variable argument $b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 12($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 4 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
j e2
|
||||||
|
e1:
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, 4($fp) #variable argument $b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, -8($fp) #variable locale
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal pgcd
|
||||||
|
addi $sp, $sp, 8 #désalocation des arguments
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0 12($fp) #Adresse de retour
|
||||||
|
addi $sp, $sp 4 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
jr $ra
|
||||||
|
e2:
|
||||||
|
addi $sp, $sp 4 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$a
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
sw $t0, $$b
|
||||||
|
lw $t0, $$b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, $$a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
li $t0, 1
|
||||||
|
blt $t1, $t2 e3
|
||||||
|
li $t0, 0
|
||||||
|
e3:
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $zero e4
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, $$a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, $$b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal pgcd
|
||||||
|
addi $sp, $sp, 8 #désalocation des arguments
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
j e5
|
||||||
|
e4:
|
||||||
|
subi $sp, $sp, 4 #Val Retour
|
||||||
|
lw $t0, $$b
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, $$a
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
jal pgcd
|
||||||
|
addi $sp, $sp, 8 #désalocation des arguments
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
e5:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,759 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>pgcd</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$c</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$c</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
<symbole>MOINS</symbole>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
<symbole>DIVISE</symbole>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
<symbole>FOIS</symbole>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionSi>
|
||||||
|
<mot_clef>si</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$c</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>alors</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionRetour>
|
||||||
|
<mot_clef>retour</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionRetour>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
<optSinon>
|
||||||
|
<mot_clef>sinon</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionRetour>
|
||||||
|
<mot_clef>retour</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>pgcd</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$c</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionRetour>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</optSinon>
|
||||||
|
</instructionSi>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionAffect>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
<symbole>EGAL</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionAffect>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionSi>
|
||||||
|
<mot_clef>si</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
<symbole>INFERIEUR</symbole>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>alors</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>pgcd</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
<optSinon>
|
||||||
|
<mot_clef>sinon</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<appelFct>
|
||||||
|
<id_fonction>pgcd</id_fonction>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<listeExpressions>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$b</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
<symbole>VIRGULE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<var>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optIndice>
|
||||||
|
</optIndice>
|
||||||
|
</var>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressionsBis>
|
||||||
|
</listeExpressions>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</appelFct>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</optSinon>
|
||||||
|
</instructionSi>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 3
|
||||||
|
sommet = 6
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 $b GLOBALE ENTIER 4 -1
|
||||||
|
2 pgcd GLOBALE FONCTION 0 2
|
||||||
|
3 $a ARGUMENT ENTIER 0 -1
|
||||||
|
4 $b ARGUMENT ENTIER 4 -1
|
||||||
|
5 $c LOCALE ENTIER 0 -1
|
||||||
|
------------------------------------------
|
||||||
|
------------------------------------------
|
||||||
|
base = 4
|
||||||
|
sommet = 4
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 $b GLOBALE ENTIER 4 -1
|
||||||
|
2 pgcd GLOBALE FONCTION 0 2
|
||||||
|
3 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_si>
|
||||||
|
<opExp>
|
||||||
|
ou
|
||||||
|
<intExp>1</intExp>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</opExp>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<intExp>5</intExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</instr_si>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
si mot_clef si
|
||||||
|
1 nombre 1
|
||||||
|
| symbole OU
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
alors mot_clef alors
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
5 nombre 5
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e0
|
||||||
|
j e2
|
||||||
|
e0 :
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
or $t0, $t1, $t2
|
||||||
|
j e3
|
||||||
|
e2 :
|
||||||
|
move $t0 $t1
|
||||||
|
e3 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $t0 $zero e4
|
||||||
|
li $t0, 5
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
j e5
|
||||||
|
e4:
|
||||||
|
e5:
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionSi>
|
||||||
|
<mot_clef>si</mot_clef>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>1</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
<symbole>OU</symbole>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<mot_clef>alors</mot_clef>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>5</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
<optSinon>
|
||||||
|
</optSinon>
|
||||||
|
</instructionSi>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 1
|
||||||
|
sommet = 1
|
||||||
|
0 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
ou
|
||||||
|
<intExp>3</intExp>
|
||||||
|
<intExp>4</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
et
|
||||||
|
<intExp>3</intExp>
|
||||||
|
<intExp>6</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
ou
|
||||||
|
<intExp>3</intExp>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
et
|
||||||
|
<intExp>3</intExp>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
ou
|
||||||
|
<intExp>0</intExp>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
et
|
||||||
|
<intExp>0</intExp>
|
||||||
|
<lireExp>
|
||||||
|
</lireExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
3 nombre 3
|
||||||
|
| symbole OU
|
||||||
|
4 nombre 4
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
3 nombre 3
|
||||||
|
& symbole ET
|
||||||
|
6 nombre 6
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
3 nombre 3
|
||||||
|
| symbole OU
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
3 nombre 3
|
||||||
|
& symbole ET
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
0 nombre 0
|
||||||
|
| symbole OU
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
0 nombre 0
|
||||||
|
& symbole ET
|
||||||
|
lire mot_clef lire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 3
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e0
|
||||||
|
j e2
|
||||||
|
e0 :
|
||||||
|
li $t0, 4
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
or $t0, $t1, $t2
|
||||||
|
j e3
|
||||||
|
e2 :
|
||||||
|
move $t0 $t1
|
||||||
|
e3 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
li $t0, 3
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e5
|
||||||
|
li $t0, 6
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t2, e5
|
||||||
|
and $t0, $t1, $t2
|
||||||
|
j e4
|
||||||
|
e5 :
|
||||||
|
li $t0 0
|
||||||
|
e4 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
li $t0, 3
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e6
|
||||||
|
j e8
|
||||||
|
e6 :
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
or $t0, $t1, $t2
|
||||||
|
j e9
|
||||||
|
e8 :
|
||||||
|
move $t0 $t1
|
||||||
|
e9 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
li $t0, 3
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e11
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t2, e11
|
||||||
|
and $t0, $t1, $t2
|
||||||
|
j e10
|
||||||
|
e11 :
|
||||||
|
li $t0 0
|
||||||
|
e10 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e12
|
||||||
|
j e14
|
||||||
|
e12 :
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
or $t0, $t1, $t2
|
||||||
|
j e15
|
||||||
|
e14 :
|
||||||
|
move $t0 $t1
|
||||||
|
e15 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
li $t0, 0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t1, e17
|
||||||
|
li $v0 5
|
||||||
|
syscall
|
||||||
|
move $t0, $v0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
beq $zero, $t2, e17
|
||||||
|
and $t0, $t1, $t2
|
||||||
|
j e16
|
||||||
|
e17 :
|
||||||
|
li $t0 0
|
||||||
|
e16 :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,375 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>3</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
<symbole>OU</symbole>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>4</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>3</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
<symbole>ET</symbole>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>6</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>3</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
<symbole>OU</symbole>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>3</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
<symbole>ET</symbole>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
<symbole>OU</symbole>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>0</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
<symbole>ET</symbole>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<mot_clef>lire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 1
|
||||||
|
sommet = 1
|
||||||
|
0 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
Fonction procedure introuvable
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<prog>
|
||||||
|
<l_dec>
|
||||||
|
<varDec>$a</varDec>
|
||||||
|
</l_dec>
|
||||||
|
<l_dec>
|
||||||
|
<foncDec>
|
||||||
|
main
|
||||||
|
<l_instr>
|
||||||
|
<instr_ecrire>
|
||||||
|
<opExp>
|
||||||
|
fois
|
||||||
|
<intExp>5</intExp>
|
||||||
|
<intExp>2</intExp>
|
||||||
|
</opExp>
|
||||||
|
</instr_ecrire>
|
||||||
|
</l_instr>
|
||||||
|
</foncDec>
|
||||||
|
</l_dec>
|
||||||
|
</prog>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
entier mot_clef entier
|
||||||
|
$a id_variable $a
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
main id_fonction main
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
{ symbole ACCOLADE_OUVRANTE
|
||||||
|
ecrire mot_clef ecrire
|
||||||
|
( symbole PARENTHESE_OUVRANTE
|
||||||
|
5 nombre 5
|
||||||
|
* symbole FOIS
|
||||||
|
2 nombre 2
|
||||||
|
) symbole PARENTHESE_FERMANTE
|
||||||
|
; symbole POINT_VIRGULE
|
||||||
|
} symbole ACCOLADE_FERMANTE
|
||||||
|
symbole FIN
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
.data
|
||||||
|
$$a: .space 4
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 5
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
li $t0, 2
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t2, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $t1, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
mult $t1, $t2
|
||||||
|
mflo $t0
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
lw $t0, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
move $a0, $t0
|
||||||
|
li $v0, 1
|
||||||
|
syscall
|
||||||
|
li $a0, '\n'
|
||||||
|
li $v0, 11
|
||||||
|
syscall
|
||||||
|
addi $sp, $sp 0 # desallocation variables locales
|
||||||
|
lw $ra, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
lw $fp, 0($sp)
|
||||||
|
addi $sp, $sp, 4
|
||||||
|
addi $sp, $sp, 4 #ignore valeur de retour
|
||||||
|
jr $ra
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<programme>
|
||||||
|
<optDecVariables>
|
||||||
|
<listeDecVariables>
|
||||||
|
<declarationVariable>
|
||||||
|
<mot_clef>entier</mot_clef>
|
||||||
|
<id_variable>$a</id_variable>
|
||||||
|
<optTailleTableau>
|
||||||
|
</optTailleTableau>
|
||||||
|
</declarationVariable>
|
||||||
|
<listeDecVariablesBis>
|
||||||
|
</listeDecVariablesBis>
|
||||||
|
</listeDecVariables>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</optDecVariables>
|
||||||
|
<listeDecFonctions>
|
||||||
|
<declarationFonction>
|
||||||
|
<id_fonction>main</id_fonction>
|
||||||
|
<listeParam>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<optListeDecVariables>
|
||||||
|
</optListeDecVariables>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
</listeParam>
|
||||||
|
<optDecVariables>
|
||||||
|
</optDecVariables>
|
||||||
|
<instructionBloc>
|
||||||
|
<symbole>ACCOLADE_OUVRANTE</symbole>
|
||||||
|
<listeInstructions>
|
||||||
|
<instruction>
|
||||||
|
<instructionEcriture>
|
||||||
|
<mot_clef>ecrire</mot_clef>
|
||||||
|
<symbole>PARENTHESE_OUVRANTE</symbole>
|
||||||
|
<expression>
|
||||||
|
<conjonction>
|
||||||
|
<negation>
|
||||||
|
<comparaison>
|
||||||
|
<expArith>
|
||||||
|
<terme>
|
||||||
|
<facteur>
|
||||||
|
<nombre>5</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
<symbole>FOIS</symbole>
|
||||||
|
<facteur>
|
||||||
|
<nombre>2</nombre>
|
||||||
|
</facteur>
|
||||||
|
<termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</termeBis>
|
||||||
|
</terme>
|
||||||
|
<expArithBis>
|
||||||
|
</expArithBis>
|
||||||
|
</expArith>
|
||||||
|
<comparaisonBis>
|
||||||
|
</comparaisonBis>
|
||||||
|
</comparaison>
|
||||||
|
</negation>
|
||||||
|
<conjonctionBis>
|
||||||
|
</conjonctionBis>
|
||||||
|
</conjonction>
|
||||||
|
<expressionBis>
|
||||||
|
</expressionBis>
|
||||||
|
</expression>
|
||||||
|
<symbole>PARENTHESE_FERMANTE</symbole>
|
||||||
|
<symbole>POINT_VIRGULE</symbole>
|
||||||
|
</instructionEcriture>
|
||||||
|
</instruction>
|
||||||
|
<listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
</listeInstructions>
|
||||||
|
<symbole>ACCOLADE_FERMANTE</symbole>
|
||||||
|
</instructionBloc>
|
||||||
|
</declarationFonction>
|
||||||
|
<listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</listeDecFonctions>
|
||||||
|
</programme>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
------------------------------------------
|
||||||
|
base = 2
|
||||||
|
sommet = 2
|
||||||
|
0 $a GLOBALE ENTIER 0 -1
|
||||||
|
1 main GLOBALE FONCTION 0 0
|
||||||
|
------------------------------------------
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
.data
|
||||||
|
.text
|
||||||
|
__start:
|
||||||
|
jal main
|
||||||
|
li $v0, 10
|
||||||
|
syscall
|
||||||
|
main :
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $fp, 0($sp)
|
||||||
|
move $fp, $sp
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $ra, 0($sp)
|
||||||
|
li $t0, 1
|
||||||
|
subi $sp, $sp, 4
|
||||||
|
sw $t0, 0($sp)
|
||||||
|
Variable $a non déclaré
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user