summaryrefslogtreecommitdiff
path: root/lib/simulator.c
diff options
context:
space:
mode:
authorPixel <>2001-04-17 03:50:21 +0000
committerPixel <>2001-04-17 03:50:21 +0000
commit1e6cd6c406e5898f2c661adce55c8dd440e36cd5 (patch)
tree404dbddb525cbdae3fa3e0a961e76660fe362806 /lib/simulator.c
parent62879bdb97d41131f5fc21ae394361566102f249 (diff)
GROUUUUUUU
Diffstat (limited to 'lib/simulator.c')
-rw-r--r--lib/simulator.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/simulator.c b/lib/simulator.c
index 40c3431..729e379 100644
--- a/lib/simulator.c
+++ b/lib/simulator.c
@@ -25,7 +25,9 @@ Uint32 LireInstruction(void)
void IncrementeCompteurOrdinal(void)
{
+ Uint32 of = LireRegistreFLAG();
EcrireRegistrePC(AdditionNonSigne(LireRegistrePC(), 1));
+ EcrireRegistreFLAG(of);
}
static FILE *openfilereading(char *name)
@@ -96,7 +98,7 @@ void DecodeExec(Uint32 instruction)
{
Uint32 champ_registre_resultat, val1, val2, resultat;
int test1, test2;
- Uint32 val; /* valeur qui va etre stockée */
+ Uint32 val, of; /* valeur qui va etre stockée */
if (Opcode(instruction) & 0x80) {
@@ -323,22 +325,30 @@ void DecodeExec(Uint32 instruction)
case 13:
if (ValeurBit(Extension(instruction), 0) == 0) {
/* RET */
+ of = LireRegistreFLAG();
EcrireRegistreSP(AdditionNonSigne(LireRegistreSP(), Champ1(instruction)));
EcrireRegistreSP(AdditionNonSigne(LireRegistreSP(), 1));
EcrireRegistrePC(LD(LireRegistreSP()));
+ EcrireRegistreFLAG(of);
} else if (ValeurBit(Extension(instruction), 1) == 0) { /* JMP */
- if (ValeurBit(Extension(instruction), 2) == 0) {
+ if (ValeurBit(Extension(instruction), 2) != 0) {
EcrireRegistrePC(LireRegistre(Champ1(instruction)));
} else {
EcrireRegistrePC(LireInstruction());
}
} else { /* CALL */
- ST(LireRegistreSP(), LireRegistrePC());
- EcrireRegistreSP(SoustractionNonSigne(LireRegistreSP(), 1));
- if (ValeurBit(Extension(instruction), 2) == 0) {
+ if (ValeurBit(Extension(instruction), 2) != 0) {
+ ST(LireRegistreSP(), LireRegistrePC());
+ of = LireRegistreFLAG();
+ EcrireRegistreSP(SoustractionNonSigne(LireRegistreSP(), 1));
+ EcrireRegistreFLAG(of);
EcrireRegistrePC(LireRegistre(Champ1(instruction)));
} else {
+ ST(LireRegistreSP(), LireRegistrePC() + 1);
+ of = LireRegistreFLAG();
+ EcrireRegistreSP(SoustractionNonSigne(LireRegistreSP(), 1));
+ EcrireRegistreFLAG(of);
EcrireRegistrePC(LireInstruction());
}
}
@@ -352,12 +362,15 @@ void DecodeExec(Uint32 instruction)
IncrementeCompteurOrdinal();
}
ST(LireRegistreSP(), val);
+ of = LireRegistreFLAG();
EcrireRegistreSP(SoustractionNonSigne(LireRegistreSP(), 1));
+ EcrireRegistreFLAG(of);
break;
case 15: /* POP */
+ of = LireRegistreFLAG();
EcrireRegistreSP(AdditionNonSigne(LireRegistreSP(), 1));
EcrireRegistre(Champ1(instruction), LD(LireRegistreSP()));
-
+ EcrireRegistreFLAG(of);
break;
case 127: /* HALT-RESET */
if (ValeurBit(Extension(instruction), 0) == 0) {