summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/assembler.c40
-rw-r--r--lib/memoire.c2
-rw-r--r--po/ProjetArchi.pot46
-rw-r--r--samples/Makefile.am2
-rw-r--r--samples/Makefile.samples12
-rw-r--r--samples/instructions.txt120
-rw-r--r--samples/rechcara.s (renamed from samples/rechcara.asm)0
-rw-r--r--samples/recherche.s (renamed from samples/recherche.asm)0
-rw-r--r--samples/sommeentiers.s (renamed from samples/sommeentiers.asm)0
9 files changed, 191 insertions, 31 deletions
diff --git a/lib/assembler.c b/lib/assembler.c
index 4abdb62..3fda135 100644
--- a/lib/assembler.c
+++ b/lib/assembler.c
@@ -1812,6 +1812,40 @@ void asm_eof(FILE * f)
break;
}
}
+ if (ttext->Expr->op == OP_DECAL) {
+ if ((ttext->Expr->child->e_subtype == E_LABEL) && (ttext->Expr->child->next->e_subtype == E_VALUE)) {
+ a = ttext->Expr->child->next->avalue;
+ nbsymbols++;
+ writeword(1, f2, 1);
+ writeword(ttext->offset, f2, 1);
+ writeword(strlen(ttext->Expr->child->symbol), f2, 1);
+ writestring(ttext->Expr->child->symbol, f2);
+ nbe++;
+ break;
+ }
+ }
+ if (ttext->Expr->op == OP_PLUS) {
+ if (((ttext->Expr->child->e_subtype == E_LABEL) && (ttext->Expr->child->next->e_subtype == E_VALUE)) || ((ttext->Expr->child->e_subtype == E_VALUE) && (ttext->Expr->child->next->e_subtype == E_LABEL))) {
+ if (ttext->Expr->child->e_subtype == E_LABEL) {
+ a = ttext->Expr->child->next->avalue;
+ nbsymbols++;
+ writeword(1, f2, 1);
+ writeword(ttext->offset, f2, 1);
+ writeword(strlen(ttext->Expr->child->symbol), f2, 1);
+ writestring(ttext->Expr->child->symbol, f2);
+ nbe++;
+ } else {
+ a = ttext->Expr->child->avalue;
+ nbsymbols++;
+ writeword(1, f2, 1);
+ writeword(ttext->offset, f2, 1);
+ writeword(strlen(ttext->Expr->child->next->symbol), f2, 1);
+ writestring(ttext->Expr->child->next->symbol, f2);
+ nbe++;
+ }
+ break;
+ }
+ }
if (ttext->Expr->op != OP_FUNC_CALL) {
exception(1, _("Can't evaluate expression for a direct value"));
}
@@ -1890,12 +1924,6 @@ void asm_eof(FILE * f)
nbe++;
break;
case E_OPERATION:
- if (tdata->Expr->op == OP_DIRECT) {
- if (tdata->Expr->child->e_subtype == E_VALUE) {
- a = tdata->Expr->child->avalue;
- break;
- }
- }
if (tdata->Expr->op != OP_FUNC_CALL) {
exception(1, _("Can't evaluate expression for a direct value"));
}
diff --git a/lib/memoire.c b/lib/memoire.c
index 869c708..ee99983 100644
--- a/lib/memoire.c
+++ b/lib/memoire.c
@@ -99,7 +99,7 @@ void ST(Uint32 offset, Uint32 valeur)
break;
case 0xffffff0a:
litchaine(temp, &memoire_principale[valeur]);
- ChargeBinaire(char * temp);
+ ChargeBinaire(temp);
default:
if (offset < 0 || offset >= TAILLE_MEMOIRE)
exception(1, _("Invalid Memory Adress"));
diff --git a/po/ProjetArchi.pot b/po/ProjetArchi.pot
index 29fad93..f6ff184 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-16 20:02+0200\n"
+"POT-Creation-Date: 2001-04-16 21:27+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"
@@ -190,7 +190,7 @@ msgstr ""
msgid "Error writing file"
msgstr ""
-#: lib/assembler.c:1753 lib/assembler.c:2078 lib/linker.c:56
+#: lib/assembler.c:1753 lib/assembler.c:2106 lib/linker.c:56
msgid "Error reading file"
msgstr ""
@@ -215,91 +215,91 @@ msgstr ""
msgid "Dumping text segment"
msgstr ""
-#: lib/assembler.c:1788 lib/assembler.c:1872 lib/assembler.c:1955
+#: lib/assembler.c:1788 lib/assembler.c:1906 lib/assembler.c:1983
#, c-format
msgid "Processing word number %i coming from line %i of the file %s."
msgstr ""
-#: lib/assembler.c:1816 lib/assembler.c:1819 lib/assembler.c:1900
-#: lib/assembler.c:1903
+#: lib/assembler.c:1850 lib/assembler.c:1853 lib/assembler.c:1928
+#: lib/assembler.c:1931
msgid "Can't evaluate expression for a direct value"
msgstr ""
-#: lib/assembler.c:1823 lib/assembler.c:1907
+#: lib/assembler.c:1857 lib/assembler.c:1935
msgid "Can only use the diff() function onto labels"
msgstr ""
-#: lib/assembler.c:1828 lib/assembler.c:1832 lib/assembler.c:1912
-#: lib/assembler.c:1916
+#: lib/assembler.c:1862 lib/assembler.c:1866 lib/assembler.c:1940
+#: lib/assembler.c:1944
msgid "Can only evaluate a diff on local symbols"
msgstr ""
-#: lib/assembler.c:1836 lib/assembler.c:1920
+#: lib/assembler.c:1870 lib/assembler.c:1948
msgid "Can only evaluate a diff on symbols from the same segment"
msgstr ""
-#: lib/assembler.c:1842 lib/assembler.c:1926
+#: lib/assembler.c:1876 lib/assembler.c:1954
msgid "Can't evaluate expression"
msgstr ""
#. Segment de data
-#: lib/assembler.c:1870
+#: lib/assembler.c:1904
msgid "Dumping data segment"
msgstr ""
#. Segment bss
-#: lib/assembler.c:1953
+#: lib/assembler.c:1981
msgid "Dumping bss segment"
msgstr ""
-#: lib/assembler.c:1999
+#: lib/assembler.c:2027
#, 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:2031
+#: lib/assembler.c:2059
msgid "Loading file"
msgstr ""
-#: lib/assembler.c:2032 lib/meta.c:516
+#: lib/assembler.c:2060 lib/meta.c:516
#, c-format
msgid "Opening file '%s'"
msgstr ""
-#: lib/assembler.c:2040 lib/meta.c:524
+#: lib/assembler.c:2068 lib/meta.c:524
msgid "Reading file"
msgstr ""
-#: lib/assembler.c:2042 lib/meta.c:526
+#: lib/assembler.c:2070 lib/meta.c:526
#, c-format
msgid "Reading line %i"
msgstr ""
-#: lib/assembler.c:2051
+#: lib/assembler.c:2079
#, c-format
msgid "Summering line %s"
msgstr ""
-#: lib/assembler.c:2070
+#: lib/assembler.c:2098
#, c-format
msgid "Assembling file %s...\n"
msgstr ""
-#: lib/assembler.c:2071
+#: lib/assembler.c:2099
msgid "Opening output file"
msgstr ""
-#: lib/assembler.c:2074
+#: lib/assembler.c:2102
msgid "Error writing output file"
msgstr ""
-#: lib/assembler.c:2080 lib/linker.c:277
+#: lib/assembler.c:2108 lib/linker.c:277
msgid "Writing output file"
msgstr ""
-#: lib/assembler.c:2081
+#: lib/assembler.c:2109
#, c-format
msgid "Generating output file %s...\n"
msgstr ""
diff --git a/samples/Makefile.am b/samples/Makefile.am
index 8235c60..1883279 100644
--- a/samples/Makefile.am
+++ b/samples/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST = rechcara.asm recherche.asm sommeentiers.asm
+EXTRA_DIST = rechcara.asm recherche.asm sommeentiers.asm Makefile.samples instructions.txt
diff --git a/samples/Makefile.samples b/samples/Makefile.samples
new file mode 100644
index 0000000..ead9b38
--- /dev/null
+++ b/samples/Makefile.samples
@@ -0,0 +1,12 @@
+.o:
+ ../src/linker $< $@
+
+.s.o:
+ ../src/compilo $< $@
+
+.s:
+ ../src/compilo $< tmp.o
+ ../src/linker tmp.o $@
+ rm tmp.o
+
+all: recherche rechcara sommeentiers
diff --git a/samples/instructions.txt b/samples/instructions.txt
new file mode 100644
index 0000000..9b70685
--- /dev/null
+++ b/samples/instructions.txt
@@ -0,0 +1,120 @@
+# Champ d'instructions général
+FI:c3,6;c2,6;c1,6;e,6;op,8
+
+# Champ d'adressage
+Fa:reserved,4;rm,2
+
+# Pattern des registres
+Pr:R0;R1;R2;R3;R4;R5;R6;R7;R8;R9;R10;R11;R12;R13;R14;R15;R16;R17;R18;R19;R20;R21;R22;R23;R24;R25;R26;R27;R28;R29;R30;R31;Rg;Rd;IP;Fl
+
+# Pattern des adressages
+# .O = Adresse absolue (relogée)
+# .O = Adresse relative à l'instruction en cours (ex: Label, Label + 2, __current__ + 4)
+Pm:regop=.Pr;.I=.O;[regop=.Pr;.I=.O[regop=.Pr
+
+# bits 3 - 2
+# ~~~~~~~~~~
+# 00 overflow
+# 01 zero
+# 10 sign
+# 11 parity
+
+# bits 5 - 4
+# ~~~~~~~~~~
+# 00 test1
+# 01 test1 || test2
+# 10 test1 && !test2
+# 11 test1 || !test2
+
+
+# Arithmetique
+
+I:ADD c1=.Pr,c2=.Pr,c3=.Pr;op=0x0;e=0x0
+I:ADD c1=.Pr,c2=.Pr,.I=.C;op=0x0;e=0x1
+I:ADU c1=.Pr,c2=.Pr,c3=.Pr;op=0x0;e=0x2
+I:ADU c1=.Pr,c2=.Pr,.I=.C;op=0x0;e=0x3
+
+p:ADS=ADD
+
+I:SUB c1=.Pr,c2=.Pr,c3=.Pr;op=0x1;e=0x0
+I:SUB c1=.Pr,c2=.Pr,.I=.C;op=0x1;e=0x1
+I:SBU c1=.Pr,c2=.Pr,c3=.Pr;op=0x1;e=0x2
+I:SBU c1=.Pr,c2=.Pr,.I=.C;op=0x1;e=0x3
+
+p:SBS=SUB
+
+I:MUL c2=.Pr,c3=.Pr;op=0x2;e=0x0
+I:MUL c2=.Pr,.I=.C;op=0x2;e=0x1
+
+I:DIV c2=.Pr,c3=.Pr;op=0x3;e=0x0
+I:DIV c2=.Pr,.I=.C;op=0x3;e=0x1
+
+I:AND c1=.Pr,c2=.Pr,c3=.Pr;op=0x4;e=0x0
+I:AND c1=.Pr,c2=.Pr,.I=.C;op=0x4;e=0x1
+
+I:OR c1=.Pr,c2=.Pr,c3=.Pr;op=0x5;e=0x0
+I:OR c1=.Pr,c2=.Pr,.I=.C;op=0x5;e=0x1
+
+I:SHL c1=.Pr,c2=.Pr,c3=.Pr;op=0x6;e=0x0
+I:SHL c1=.Pr,c2=.Pr,I=.C;op=0x6;e=0x1
+
+I:SHR c1=.Pr,c2=.Pr,c3=.Pr;op=0x7;e=0x0
+I:SHR c1=.Pr,c2=.Pr,.I=.C;op=0x7;e=0x1
+
+
+# Transferts
+
+I:MOV c1=.Pr,rm=.Pm;op=8;e=0;c2=.Fa;c3=regop
+I:MOV c1=.Pr,c3=.Pr;op=8;e=0;c2=0
+I:MOV c1=.Pr,.I=.C;op=8;e=1
+I:MOV rm=.Pm,c2=.Pr;op=8;e=2;c1=.Fa;c3=regop
+I:MOV rm=.Pm,.I=.C;op=8;e=3;c1=.Fa;c3=regop
+
+p:MV=MOV
+
+
+# Misc1
+
+I:NOP;op=0x9
+
+
+# Branchements
+
+# bits 3 - 2
+# ~~~~~~~~~~
+# 00 overflow
+# 01 zero
+# 10 sign
+# 11 parity
+
+# bits 5 - 4
+# ~~~~~~~~~~
+# 00 test1
+# 01 test1 || test2 == !(!test1 && !test2)
+# 10 test1 && !test2 == !(!test1 || test2)
+# 11 test1 || !test2 == !(!test1 && test2)
+
+I:JE c1=.Pr,c2=.Pr,.I=.O;op=0xa;e=0x0
+I:JNE c1=.Pr,c2=.Pr,.I=.O;op=0xa;e=0x1
+I:JL c1=.Pr,c2=.Pr,.I=.O;op=0xa;e=0x2
+I:JLE c1=.Pr,c2=.Pr,.I=.O;op=0xa;e=0x3
+I:JG c2=.Pr,c1=.Pr,.I=.O;op=0xa;e=0x2
+I:JGE c2=.Pr,c1=.Pr,.I=.O;op=0xa;e=0x3
+
+I:JO .I=.O;op=0xa;e=0x10
+I:JZ .I=.O;op=0xa;e=0x14
+I:JS .I=.O;op=0xa;e=0x18
+I:JP .I=.O;op=0xa;e=0x1c
+
+I:JNO .I=.O;op=0xa;e=0x30
+I:JNZ .I=.O;op=0xa;e=0x34
+I:JNS .I=.O;op=0xa;e=0x38
+I:JNP .I=.O;op=0xa;e=0x3c
+
+I:JMP .I=.O;op=0x0c;e=0x2
+
+I:HALT;op=0x7f
+I:RESET;op=0x7f;e=1
+
+I:RET;op=0xc
+I:RET c1=.C;op=0xc
diff --git a/samples/rechcara.asm b/samples/rechcara.s
index c4747c3..c4747c3 100644
--- a/samples/rechcara.asm
+++ b/samples/rechcara.s
diff --git a/samples/recherche.asm b/samples/recherche.s
index 46b979e..46b979e 100644
--- a/samples/recherche.asm
+++ b/samples/recherche.s
diff --git a/samples/sommeentiers.asm b/samples/sommeentiers.s
index 2e533a7..2e533a7 100644
--- a/samples/sommeentiers.asm
+++ b/samples/sommeentiers.s