summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <>2001-04-23 21:09:03 +0000
committerPixel <>2001-04-23 21:09:03 +0000
commit5796178981fe51ea279b56a2dca19cf19fb73edf (patch)
treec630f6d1ae5356870c7590c690cea29679ae69b2
parenta3456122423c7784a5f72c202f3636256e0da7c9 (diff)
Bug dans le simulateur (2) et ajout de l'exemple "Puissance4"
-rw-r--r--lib/simulator.c6
-rw-r--r--po/ProjetArchi.pot2
-rw-r--r--samples/Makefile.samples2
-rw-r--r--samples/p4.s123
4 files changed, 128 insertions, 5 deletions
diff --git a/lib/simulator.c b/lib/simulator.c
index f2749e0..c7c709c 100644
--- a/lib/simulator.c
+++ b/lib/simulator.c
@@ -228,14 +228,14 @@ void DecodeExec(Uint32 instruction)
/* Pas de MOV conditionnel */
if (ValeurBit(Extension(instruction), 1) == 0) { /* Mov arg1 arg2 */
if (ValeurBit(Extension(instruction), 0) == 0) { /* arg2 = reg */
- if (champ(Champ1(instruction), 2) == 0) { /* r/m de arg1 = 0 */
+ if (champ(Champ1(instruction), 4) == 0) { /* r/m de arg1 = 0 */
EcrireRegistre(Champ3(instruction), LireRegistre(Champ2(instruction)));
} else {
ST(Adresse
(Champ1(instruction), instruction), LireRegistre(Champ2(instruction)));
}
} else { /* arg2 = imm32 */
- if (champ(Champ1(instruction), 2) == 0) { /* r/m de arg1 = 0 */
+ if (champ(Champ1(instruction), 4) == 0) { /* r/m de arg1 = 0 */
EcrireRegistre(Champ3(instruction), LireInstruction());
IncrementeCompteurOrdinal();
} else {
@@ -246,7 +246,7 @@ void DecodeExec(Uint32 instruction)
}
} else { /* mov arg2, arg1 */
if (ValeurBit(Extension(instruction), 0) == 0) { /* arg2 = reg */
- if (champ(Champ1(instruction), 2) == 0) { /* r/m de arg1 = 0 */
+ if (champ(Champ1(instruction), 4) == 0) { /* r/m de arg1 = 0 */
EcrireRegistre(Champ2(instruction), LireRegistre(Champ3(instruction)));
} else {
EcrireRegistre(Champ2
diff --git a/po/ProjetArchi.pot b/po/ProjetArchi.pot
index a27e071..a032bed 100644
--- a/po/ProjetArchi.pot
+++ b/po/ProjetArchi.pot
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2001-04-23 20:56+0200\n"
+"POT-Creation-Date: 2001-04-23 23:07+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
diff --git a/samples/Makefile.samples b/samples/Makefile.samples
index 978d9d0..6b1eac0 100644
--- a/samples/Makefile.samples
+++ b/samples/Makefile.samples
@@ -10,7 +10,7 @@
chmod 755 $@
rm tmp.o
-all: helloworld hello recherche rechcara sommeentiers testtout boucle
+all: helloworld hello recherche rechcara sommeentiers testtout boucle p4
helloworld: fichier1.s fichier2.s
../src/compilo fichier1.s fichier1.o
diff --git a/samples/p4.s b/samples/p4.s
new file mode 100644
index 0000000..28b79fd
--- /dev/null
+++ b/samples/p4.s
@@ -0,0 +1,123 @@
+.bss
+Table DR 9 * 9 ; Table du jeu
+
+.data
+
+;
+; Les quelques textes qui seront affichés
+;
+
+MsgTour1 DS "C'est au tour du joueur "
+MsgTour2 DS " de jouer\n"
+MsgGagne1 DS "Le joueur "
+MsgGagne2 DS " a gagné\n"
+MsgDraw DS "| "
+MsgDrawJ1 DS "|\e[31m;O\e[0m;"
+MsgDrawJ2 DS "|\e[34m;O\e[0m;"
+MsgDrawWall DS "|\n"
+MsgsDraw DD MsgDraw, MsgDrawJ1, MsgDrawJ2, MsgDraw
+MsgDrawBegin DS "\e[2J 1 2 3 4 5 6 7\n"
+MsgDrawEnd DS "+-+-+-+-+-+-+-+\n"
+
+.text
+
+;
+;
+; Registre globaux: R0 = 0, R1 = @Table, R2 = Joueur en cours, R3 = nombre de coups à jouer
+;
+;
+
+
+;
+; Initialisations
+;
+
+InitP4: PUSH R4
+ PUSH R5
+ PUSH R6
+
+ MOV R1, Table
+ MOV R2, 1
+ MOV R3, 7 * 7;
+
+ ; On met tout à zéro.
+ MOV R4, Table + (9 * 9);
+ MOV R5, R1
+BoucleInit1: MOV, [R5], R0
+ ADD R5, 1
+ JNE R5, R4, BoucleInit1
+
+ ; On met à 3 les 'murs' gauche et droite.
+ MOV R5, R1
+ MOV R6, 3
+BoucleInit2: MOV, [R5], R6
+ MOV, [R5 + 8], R6
+ ADD R5, 1
+ JNE R5, R4, BoucleInit2
+
+ ; On met à 3 les 'murs' haut et bas.
+ MOV R4, Table + 9;
+ MOV R5, R1
+BoucleInit3: MOV, [R5], R6
+ MOV, [R5 + (8 * 9)], R6
+ ADD R5, 1
+ JNE R5, R4, BoucleInit3
+
+ POP R6
+ POP R5
+ POP R4
+ RET
+
+
+;
+; Sert à lire un mot de la table du P4, coordonnées (R7, R8), et renvoie le résultat dans R9
+;
+
+LitMot: PUSH R4
+
+ MOV R4, 9
+ MUL R4, R8
+ ADD R4, Rd, R1
+ ADD R4, R7
+ MOV R9, [R4]
+
+ POP R4
+ RET
+
+
+;
+; Sert à afficher la table.
+;
+
+AfficheP4: PUSH R4
+ PUSH R5
+ PUSH R6
+ PUSH R7
+ PUSH R8
+ PUSH R9
+
+ MOV, [0xffffff04], MsgDrawBegin
+
+ MOV R5, Table + 9;
+ ADD R4, R5, 7 * 9;
+
+BoucleAffiche: MOV R9, [R5]
+ MOV R6, Table[R9]
+ MOV, [0xffffff04], R6
+ ADD R5, 1
+ JNE R5, R4, BoucleAffiche
+
+ MOV, [0xffffff04], MsgDrawEnd
+
+ POP R9
+ POP R8
+ POP R7
+ POP R6
+ POP R5
+ POP R4
+ RET
+
+.start
+ CALL InitP4
+ CALL AfficheP4
+ HALT