Browse Source

Aggiunto modulo governo, makefile, main.

Daniele Lacamera 4 years ago
parent
commit
88f85bc8a5
7 changed files with 102 additions and 10 deletions
  1. 8 0
      Makefile
  2. 9 9
      accumulatore.c
  3. 1 0
      codifica_istruzioni.h
  4. 5 0
      elea.c
  5. 22 1
      elea_tipi.h
  6. 32 0
      governo.c
  7. 25 0
      governo.h

+ 8 - 0
Makefile

@@ -0,0 +1,8 @@
+CC=gcc
+
+elea: elea.o governo.o accumulatore.o
+
+clean: FORCE
+	@rm -f elea *.o tags
+
+.PHONY: FORCE

+ 9 - 9
accumulatore.c

@@ -1,8 +1,8 @@
 #include "elea_tipi.h"
+#include "governo.h"
 
-statico carattere Accumulatore[100];
-statico int REG_DA = 0;
-statico segno REG_SEGNO_A = 0;
+static carattere Accumulatore[100];
+static segno REG_SEGNO_A = 0;
 
 /* Da accumulatore a memoria */
 int AoM(carattere *mem, int lun)
@@ -10,7 +10,7 @@ int AoM(carattere *mem, int lun)
     int i;
     int pos;
     for (i = 0; i < lun; i++) {
-        pos = (REG_DA + lun - (i + 1));
+        pos = (R.P + lun - (i + 1));
         mem[i] = (Accumulatore[pos] & 0x7F);
         Accumulatore[pos] = 0x80;
     } 
@@ -25,17 +25,17 @@ int MA(const carattere *mem, int lun)
     
     for (i = 0; i < lun; i++) {
         pos = (lun - (i + 1));
-        Accumulatore[REG_DA + i] = (mem[pos] & 0x7F);
-        Accumulatore[REG_DA + i] &= ~0x80;
+        Accumulatore[R.P + i] = (mem[pos] & 0x7F);
+        Accumulatore[R.P + i] &= ~0x80;
     }
     /* accende gA nell'ultimo carattere */
-    Accumulatore[REG_DA + lun - 1] |= 0x80;
+    Accumulatore[R.P + lun - 1] |= 0x80;
 }
 
 int DA(const int disp)
 {
     if (disp < 0 || disp > 99)
         return -1;
-    REG_DA = disp; 
-    return REG_DA;
+    R.P = disp; 
+    return R.P;
 }

+ 1 - 0
codifica_istruzioni.h

@@ -1,4 +1,5 @@
 #include "elea_tipi.h"
+#include "conf_caratteri.h"
 
 
 /*

+ 5 - 0
elea.c

@@ -0,0 +1,5 @@
+/* main */
+int main(int argc, char *argv[])
+{
+    return 0;
+}

+ 22 - 1
elea_tipi.h

@@ -1,6 +1,14 @@
-#define statico static
+#ifndef ELEA_TIPI_INCLUSO
+#define ELEA_TIPI_INCLUSO
+
+#include <stdint.h>
+
+
 typedef uint8_t carattere;
 typedef int8_t segno;
+typedef uint8_t booleano;
+#define SI (1)
+#define NO (0)
 
 
 
@@ -10,6 +18,9 @@ typedef int8_t segno;
  */
 #define gA(x) ((x >> 7) & 0x01)
 
+typedef carattere * indirizzo;
+
+
 
 struct __attribute__((packed)) istruzione_gen {
     carattere F;    /* Tipo di funzione */
@@ -48,3 +59,13 @@ struct __attribute__((packed)) istruzione_n {
     carattere n;     /* Unita` nastro */
     carattere X;     /* Non utilizzato */
 };
+
+typedef union u_istruzione {
+    struct istruzione_gen gen;
+    struct istruzione_t   t;
+    struct istruzione_c   c;
+    struct istruzione_s   s;
+    struct istruzione_n   n;
+} istruzione;
+
+#endif /* ELEA_TIPI_INCLUSO */

+ 32 - 0
governo.c

@@ -0,0 +1,32 @@
+#include "elea_tipi.h"
+#include "governo.h"
+
+struct registri_sistema R; 
+
+static operazione *OP[64] = { };
+
+static booleano CanaleInternoOcc = NO;
+static booleano CanaleEsternoOcc = NO;
+
+static uint32_t N_Cicli = 0; 
+
+booleano canale_interno_occupato(void)
+{
+    return CanaleInternoOcc;
+}
+
+booleano canale_esterno_occupato(void)
+{
+    return CanaleEsternoOcc;
+}
+
+void esegui_primo_programma(void)
+{
+    istruzione *i = R.I;
+    carattere F = *((carattere *)i);
+    if (OP[F] != (operazione *)0) {
+        (*OP[F])(i);
+    } else {
+        /* TODO: fault */
+    }
+}

+ 25 - 0
governo.h

@@ -0,0 +1,25 @@
+#ifndef GOVERNO_INCLUSO
+#define GOVERNO_INCLUSO
+
+#include "elea_tipi.h"
+
+struct registri_sistema {
+    istruzione *I; /* Indirizzo istruzione primo programma */
+    istruzione *O; /* Indirizzo operando in memoria */
+    istruzione *M; /* Indirizzo istruzione secondo programma */
+    int         P; /* Indice accumulatore */
+    indirizzo   Q; /* Indirizzo di accum. in moltipl. */
+    indirizzo   R; /* Indirizzo moltiplic. in To */
+    istruzione *H; /* Indirizzo istruzione terzo programma */
+    int         N; /* Memorizzatore di W per telescrivente */
+    int         S; /* Memorizzatore di R per telescrivente */
+    int         Z; /* ? */
+};
+
+extern struct registri_sistema R; /* Globale, definito in governo.c */
+
+typedef int(*operazione)(istruzione *I);
+
+void esegui_primo_programma(void);
+
+#endif