summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <>2001-04-17 01:04:24 +0000
committerPixel <>2001-04-17 01:04:24 +0000
commit17d89e026ee39bd30f8604ab397708d9bceb2fbf (patch)
tree29e7053661656203ae56db7439de9b5c8de293b1
parent4f2aa7d436bb50cef3f9a551f79fa03ea275ab77 (diff)
GRou
-rw-r--r--include/memoire.h2
-rw-r--r--include/simulator.h1
-rw-r--r--lib/memoire.c2
-rw-r--r--lib/simulator.c11
-rw-r--r--po/ProjetArchi.pot164
-rw-r--r--po/cat-id-tbl.c18
-rw-r--r--src/simul.c109
7 files changed, 210 insertions, 97 deletions
diff --git a/include/memoire.h b/include/memoire.h
index b20434e..88c9def 100644
--- a/include/memoire.h
+++ b/include/memoire.h
@@ -5,5 +5,5 @@ extern Uint32 * memoire_principale;
Uint32 LD(Uint32 offset);
void ST(Uint32 offset, Uint32 valeur);
void InitMemoire(void);
-void FreeMemoire(void);
+void FlushMemoire(void);
#endif
diff --git a/include/simulator.h b/include/simulator.h
index 41afe2c..a6350e7 100644
--- a/include/simulator.h
+++ b/include/simulator.h
@@ -17,6 +17,7 @@ extern Uint32 registre[NB_REGISTRES_PHYSIQUES]; /* Registres classiques */
extern int debug;
void Initialisation(void);
+void Flush(void);
void ChargeBinaire(char * filename);
#endif \ No newline at end of file
diff --git a/lib/memoire.c b/lib/memoire.c
index ae79d18..db85ae9 100644
--- a/lib/memoire.c
+++ b/lib/memoire.c
@@ -28,7 +28,7 @@ void InitMemoire(void)
memoire_principale = (Uint32 *) Emalloc(TAILLE_MEMOIRE * sizeof(Uint32));
}
-void FreeMemoire(void)
+void FlushMemoire(void)
{
free(memoire_principale);
}
diff --git a/lib/simulator.c b/lib/simulator.c
index 61c96d5..4e77c6b 100644
--- a/lib/simulator.c
+++ b/lib/simulator.c
@@ -3,12 +3,7 @@
#include <string.h>
#include <errno.h>
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#else
-#define _(x) x
-#endif
-
#include "alu.h"
#include "simulator.h"
#include "interne.h"
@@ -93,6 +88,10 @@ void Initialisation(void)
EcrireRegistreSP(ADD_SP); /* initialisation du stack pointer */
}
+void Flush(void) {
+ FlushMemoire();
+}
+
void DecodeExec(Uint32 instruction)
{
Uint32 champ_registre_resultat, val1, val2, resultat;
@@ -431,7 +430,7 @@ void Debogueur(void)
}
void Traitement(Uint32 entrypoint)
-{ /* ******************** FIXMI ************************* */
+{
Uint32 instruction;
while (HasToRun) {
diff --git a/po/ProjetArchi.pot b/po/ProjetArchi.pot
index 2d6ef39..7f38f3e 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-17 02:32+0200\n"
+"POT-Creation-Date: 2001-04-17 02:59+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"
@@ -123,184 +123,184 @@ msgstr ""
msgid "Something wrong, should never got here..."
msgstr ""
-#: lib/assembler.c:1283
+#: lib/assembler.c:1284
msgid "Unknow predefined string into the meta language"
msgstr ""
-#: lib/assembler.c:1337
+#: lib/assembler.c:1339
msgid "Pattern not matching..."
msgstr ""
-#: lib/assembler.c:1345 lib/assembler.c:1375 lib/assembler.c:1626
-#: lib/assembler.c:1642 lib/assembler.c:1657
+#: lib/assembler.c:1347 lib/assembler.c:1377 lib/assembler.c:1628
+#: lib/assembler.c:1644 lib/assembler.c:1662
msgid "Unknow constant type in the meta language"
msgstr ""
-#: lib/assembler.c:1357 lib/assembler.c:1399 lib/assembler.c:1426
+#: lib/assembler.c:1359 lib/assembler.c:1401 lib/assembler.c:1428
msgid ""
"Error in the metalanguage (pattern should be here if not a constant type)"
msgstr ""
-#: lib/assembler.c:1387 lib/assembler.c:1412 lib/assembler.c:1420
-#: lib/assembler.c:1686
+#: lib/assembler.c:1389 lib/assembler.c:1414 lib/assembler.c:1422
+#: lib/assembler.c:1693
msgid "Logical error in meta language"
msgstr ""
-#: lib/assembler.c:1455
+#: lib/assembler.c:1457
msgid "Unknow field in metalanguage"
msgstr ""
-#: lib/assembler.c:1465
+#: lib/assembler.c:1467
msgid "Can't evaluate directly expression"
msgstr ""
-#: lib/assembler.c:1471
+#: lib/assembler.c:1473
msgid "Value too large for field"
msgstr ""
-#: lib/assembler.c:1522 lib/assembler.c:1712
+#: lib/assembler.c:1524 lib/assembler.c:1723
msgid "Unknow instruction"
msgstr ""
-#: lib/assembler.c:1547
+#: lib/assembler.c:1549
msgid "Unknow constant"
msgstr ""
-#: lib/assembler.c:1556
+#: lib/assembler.c:1558
msgid "Bad constant for an immediate value"
msgstr ""
-#: lib/assembler.c:1573
+#: lib/assembler.c:1575
msgid "Bad constant for a string"
msgstr ""
-#: lib/assembler.c:1590
+#: lib/assembler.c:1592
msgid "Bad array size"
msgstr ""
-#: lib/assembler.c:1600
+#: lib/assembler.c:1602
msgid "You can only have an instruction into a .text segment"
msgstr ""
-#: lib/assembler.c:1603
+#: lib/assembler.c:1605
msgid "Unmatched instruction"
msgstr ""
-#: lib/assembler.c:1736 lib/assembler.c:1778 lib/linker.c:45 lib/linker.c:67
+#: lib/assembler.c:1748 lib/assembler.c:1790 lib/linker.c:45 lib/linker.c:67
msgid "Error writing file"
msgstr ""
-#: lib/assembler.c:1787 lib/assembler.c:2155 lib/linker.c:56
-#: lib/simulator.c:42
+#: lib/assembler.c:1799 lib/assembler.c:2187 lib/linker.c:56
+#: lib/simulator.c:37
msgid "Error reading file"
msgstr ""
-#: lib/assembler.c:1804
+#: lib/assembler.c:1816
msgid "Creating temporary files"
msgstr ""
-#: lib/assembler.c:1807
+#: lib/assembler.c:1819
msgid "Error writing file __text__"
msgstr ""
-#: lib/assembler.c:1811
+#: lib/assembler.c:1823
msgid "Error writing file __symbols__"
msgstr ""
-#: lib/assembler.c:1815
+#: lib/assembler.c:1827
msgid "Dumping memory into object file"
msgstr ""
#. Segment de texte
-#: lib/assembler.c:1820
+#: lib/assembler.c:1832
msgid "Dumping text segment"
msgstr ""
-#: lib/assembler.c:1822 lib/assembler.c:1952 lib/assembler.c:2032
+#: lib/assembler.c:1834 lib/assembler.c:1976 lib/assembler.c:2062
#, c-format
msgid "Processing word number %i coming from line %i of the file %s."
msgstr ""
-#: lib/assembler.c:1895 lib/assembler.c:1898 lib/assembler.c:1976
-#: lib/assembler.c:1979
+#: lib/assembler.c:1917 lib/assembler.c:1920 lib/assembler.c:2004
+#: lib/assembler.c:2007
msgid "Can't evaluate expression for a direct value"
msgstr ""
-#: lib/assembler.c:1902 lib/assembler.c:1983
+#: lib/assembler.c:1924 lib/assembler.c:2011
msgid "Can only use the diff() function onto labels"
msgstr ""
-#: lib/assembler.c:1907 lib/assembler.c:1911 lib/assembler.c:1988
-#: lib/assembler.c:1992
+#: lib/assembler.c:1929 lib/assembler.c:1933 lib/assembler.c:2016
+#: lib/assembler.c:2020
msgid "Can only evaluate a diff on local symbols"
msgstr ""
-#: lib/assembler.c:1915 lib/assembler.c:1996
+#: lib/assembler.c:1937 lib/assembler.c:2024
msgid "Can only evaluate a diff on symbols from the same segment"
msgstr ""
-#: lib/assembler.c:1921 lib/assembler.c:2002
+#: lib/assembler.c:1943 lib/assembler.c:2030
msgid "Can't evaluate expression"
msgstr ""
#. Segment de data
-#: lib/assembler.c:1950
+#: lib/assembler.c:1974
msgid "Dumping data segment"
msgstr ""
#. Segment bss
-#: lib/assembler.c:2030
+#: lib/assembler.c:2060
msgid "Dumping bss segment"
msgstr ""
-#: lib/assembler.c:2077
+#: lib/assembler.c:2109
#, c-format
msgid ""
"Statistics: %i words of text, %i words of data, and %i words reserved.\n"
"%i symbols generated with %i internal and %i external.\n"
msgstr ""
-#: lib/assembler.c:2106
+#: lib/assembler.c:2138
msgid "Loading file"
msgstr ""
-#: lib/assembler.c:2107 lib/meta.c:516
+#: lib/assembler.c:2139 lib/meta.c:516
#, c-format
msgid "Opening file '%s'"
msgstr ""
-#: lib/assembler.c:2116 lib/meta.c:524
+#: lib/assembler.c:2148 lib/meta.c:524
msgid "Reading file"
msgstr ""
-#: lib/assembler.c:2118 lib/meta.c:526
+#: lib/assembler.c:2150 lib/meta.c:526
#, c-format
msgid "Reading line %i"
msgstr ""
-#: lib/assembler.c:2127
+#: lib/assembler.c:2159
#, c-format
msgid "Summering line %s"
msgstr ""
-#: lib/assembler.c:2146
+#: lib/assembler.c:2178
#, c-format
msgid "Assembling file %s...\n"
msgstr ""
-#: lib/assembler.c:2147
+#: lib/assembler.c:2179
msgid "Opening output file"
msgstr ""
-#: lib/assembler.c:2150
+#: lib/assembler.c:2182
msgid "Error writing output file"
msgstr ""
-#: lib/assembler.c:2157 lib/linker.c:281
+#: lib/assembler.c:2189 lib/linker.c:278
msgid "Writing output file"
msgstr ""
-#: lib/assembler.c:2158
+#: lib/assembler.c:2190
#, c-format
msgid "Generating output file %s...\n"
msgstr ""
@@ -449,7 +449,7 @@ msgstr ""
msgid "FPU not implemented"
msgstr ""
-#: lib/memoire.c:55 lib/memoire.c:124
+#: lib/memoire.c:57 lib/memoire.c:130
msgid "Invalid Memory Adress"
msgstr ""
@@ -458,7 +458,7 @@ msgstr ""
msgid "Invalid Register Descriptor"
msgstr ""
-#: lib/linker.c:76 lib/simulator.c:52
+#: lib/linker.c:76 lib/simulator.c:47
msgid "premature end of file"
msgstr ""
@@ -488,62 +488,62 @@ msgstr ""
msgid "Symbol %s not found"
msgstr ""
-#: lib/linker.c:238 lib/linker.c:260 lib/linker.c:267
+#: lib/linker.c:235 lib/linker.c:257 lib/linker.c:264
msgid "Internal error"
msgstr ""
-#: lib/linker.c:285
+#: lib/linker.c:282
msgid "No startpoint defined."
msgstr ""
-#: lib/linker.c:288
+#: lib/linker.c:285
msgid "Writing headers"
msgstr ""
-#: lib/linker.c:297
+#: lib/linker.c:294
msgid "Writing relocating informations"
msgstr ""
-#: lib/linker.c:300
+#: lib/linker.c:297
msgid "Writing text segments"
msgstr ""
-#: lib/linker.c:305
+#: lib/linker.c:302
msgid "Writing data segments"
msgstr ""
-#: lib/linker.c:312
+#: lib/linker.c:309
#, c-format
msgid "Statistics: %i words of text, %i words of data and reserving %i words\n"
msgstr ""
-#: lib/linker.c:314
+#: lib/linker.c:311
#, c-format
msgid "Output file size: %i words containing %i relocating offsets.\n"
msgstr ""
-#: lib/simulator.c:63
+#: lib/simulator.c:58
msgid "Adresse: Call With Invalid r/m Field State ( r/m=00 )"
msgstr ""
-#: lib/simulator.c:76
+#: lib/simulator.c:71
msgid "Adresse: Unmatched Addr Field"
msgstr ""
#. arg2 = imm32
-#: lib/simulator.c:250
+#: lib/simulator.c:249
msgid "MOV: Memory to Memory Forbidden On This Type Of Processor"
msgstr ""
-#: lib/simulator.c:372
+#: lib/simulator.c:371
msgid "DecodeExec: Invalid Opcode"
msgstr ""
-#: lib/simulator.c:424
+#: lib/simulator.c:425
msgid "Shutdown requested"
msgstr ""
-#: lib/simulator.c:426
+#: lib/simulator.c:427
msgid ""
"Help:\n"
"G: go\n"
@@ -553,25 +553,25 @@ msgid ""
msgstr ""
#. verification de la signature
-#: lib/simulator.c:465
+#: lib/simulator.c:462
msgid "Invalid Signature"
msgstr ""
-#: lib/simulator.c:468
+#: lib/simulator.c:465
#, c-format
msgid "Loading file %s"
msgstr ""
-#: lib/simulator.c:503
+#: lib/simulator.c:499
#, c-format
msgid "Executing file %s"
msgstr ""
-#: lib/terminal.c:22
+#: lib/terminal.c:23
msgid "could not set terminal attributes"
msgstr ""
-#: lib/terminal.c:33
+#: lib/terminal.c:36
msgid "could not open terminal"
msgstr ""
@@ -609,32 +609,50 @@ msgstr ""
msgid "Assembler core init failed."
msgstr ""
-#: src/compilo.c:45 src/linker.c:27
+#: src/compilo.c:45 src/linker.c:27 src/simul.c:30
msgid " Done!\n"
msgstr ""
-#: src/compilo.c:56 src/linker.c:37
+#: src/compilo.c:56 src/linker.c:37 src/simul.c:40
msgid "Signal received: segfault"
msgstr ""
-#: src/compilo.c:68 src/linker.c:51
+#: src/compilo.c:68 src/linker.c:51 src/simul.c:93
msgid ""
"\n"
"Performing initialisation...\n"
"\n"
msgstr ""
-#: src/compilo.c:73 src/linker.c:63
+#: src/compilo.c:73 src/linker.c:63 src/simul.c:106
msgid ""
"\n"
"Performing shutdown...\n"
"\n"
msgstr ""
-#: src/compilo.c:76 src/linker.c:66
+#: src/compilo.c:76 src/linker.c:66 src/simul.c:109
msgid "Exitting, bye!\n"
msgstr ""
+#: src/simul.c:16
+msgid ""
+"Simul v1.0\n"
+"\n"
+msgstr ""
+
+#: src/simul.c:21
+msgid "Usage: linker [-q] [-d] binary\n"
+msgstr ""
+
+#: src/simul.c:27
+msgid " o Initialising the simulator... "
+msgstr ""
+
+#: src/simul.c:96
+msgid "Beginning simulation"
+msgstr ""
+
#: src/linker.c:13
msgid ""
"Linker v1.0\n"
diff --git a/po/cat-id-tbl.c b/po/cat-id-tbl.c
index 2a5d02a..9b62514 100644
--- a/po/cat-id-tbl.c
+++ b/po/cat-id-tbl.c
@@ -171,12 +171,18 @@ Performing shutdown...\n\
\n", 142},
{"Exitting, bye!\n", 143},
{"\
-Linker v1.0\n\
+Simul v1.0\n\
\n", 144},
- {"Usage: linker obj1 [obj2 [obj3 [...]]] binary\n", 145},
- {" o Initialising the linker... ", 146},
- {"Linking files...\n", 147},
- {"Generating output file...\n", 148},
+ {"Usage: linker [-q] [-d] binary\n", 145},
+ {" o Initialising the simulator... ", 146},
+ {"Beginning simulation", 147},
+ {"\
+Linker v1.0\n\
+\n", 148},
+ {"Usage: linker obj1 [obj2 [obj3 [...]]] binary\n", 149},
+ {" o Initialising the linker... ", 150},
+ {"Linking files...\n", 151},
+ {"Generating output file...\n", 152},
};
-int _msg_tbl_length = 148;
+int _msg_tbl_length = 152;
diff --git a/src/simul.c b/src/simul.c
index 1ae3d55..45c8092 100644
--- a/src/simul.c
+++ b/src/simul.c
@@ -1,22 +1,111 @@
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
-#ifdef HAVE_CONFIG_H
#include "config.h"
-#else
-#define _(x) x
-#endif
-
#include "simulator.h"
#include "alu.h"
#include "terminal.h"
+#include "exceptions.h"
+
+typedef void (*sighandler_t) (int);
-int main(void)
+void invite(void)
{
- openterm();
- Rapide = 1;
+ fprintf(stderr, _("Simul v1.0\n\n"));
+}
+
+void usage(void)
+{
+ fprintf(stderr, _("Usage: linker [-q] [-d] binary\n"));
+ exit(0);
+}
+
+void init_all(void)
+{
+ fprintf(stderr, _(" o Initialising the simulator... "));
+
Initialisation();
+ fprintf(stderr, _(" Done!\n"));
+}
+
+void flush_all(void)
+{
+ Flush();
+}
+
+void segfaulthand(int i)
+{
+ exception(1, _("Signal received: segfault"));
+}
+
+void ctrlbreakhand(int i) {
debug = 1;
- ChargeBinaire("progtest");
+}
+
+char * readargs(int argc, char ** argv) {
+ char * r = NULL;
+
+ argc--;
+ argv++;
+
+ while (argc) {
+ if (**argv == '-') {
+ switch ((*argv)[1]) {
+ case 'q':
+ Rapide = 1;
+ break;
+ case 'd':
+ debug = 1;
+ break;
+ default:
+ usage();
+ }
+ } else {
+ if (r) {
+ usage();
+ }
+ r = *argv;
+ }
+ argv++;
+ argc--;
+ }
+
+ if (!r) {
+ usage();
+ }
+ return r;
+}
+
+int main(int argc, char **argv)
+{
+ int i;
+ char * nom;
+
+ invite();
+
+ nom = readargs(argc, argv);
+
+ signal(SIGSEGV, segfaulthand);
+ signal(SIGINT, ctrlbreakhand);
+
+ fprintf(stderr, _("\nPerforming initialisation...\n\n"));
+ init_all();
+
+ pushcontext(_("Beginning simulation"));
+
+ openterm();
+ initterm();
+ clearterm();
+ ChargeBinaire(nom);
clearterm();
- return (0);
+
+ popcontext();
+
+ fprintf(stderr, _("\nPerforming shutdown...\n\n"));
+ flush_all();
+
+ fprintf(stderr, _("Exitting, bye!\n"));
+ return 0;
}