Browse Source

Aggiunti moduli unita` centrale

Daniele Lacamera 4 years ago
parent
commit
07fc47c2c8
14 changed files with 323 additions and 7 deletions
  1. 1 1
      Makefile
  2. 45 0
      accumulatore.c
  3. 14 0
      accumulatore.h
  4. 85 0
      algebra.c
  5. 22 0
      algebra.h
  6. 4 4
      conf_caratteri.h
  7. 77 1
      governo.c
  8. 1 1
      governo.h
  9. 27 0
      memoria.c
  10. 9 0
      memoria.h
  11. 10 0
      ricerca.c
  12. 7 0
      ricerca.h
  13. 13 0
      telescrivente.c
  14. 8 0
      telescrivente.h

+ 1 - 1
Makefile

@@ -1,6 +1,6 @@
 CC=gcc
 
-elea: elea.o governo.o accumulatore.o
+elea: elea.o governo.o accumulatore.o memoria.o ricerca.o algebra.o telescrivente.o
 
 clean: FORCE
 	@rm -f elea *.o tags

+ 45 - 0
accumulatore.c

@@ -39,3 +39,48 @@ int DA(const int disp)
     R.P = disp; 
     return R.P;
 }
+
+int op_da(istruzione *i)
+{
+    return 0;
+}
+
+int op_fam(istruzione *i)
+{
+    return 0;
+}
+
+int op_aom(istruzione *i)
+{
+    return 0;
+}
+int op_piu_ma(istruzione *i)
+{
+    return 0;
+}
+
+int op_cma(istruzione *i)
+{
+    return 0;
+}
+
+int op_ma(istruzione *i)
+{
+    return 0;
+}
+
+int op_am(istruzione *i)
+{
+    return 0;
+}
+
+int op_piu_am(istruzione *i)
+{
+    return 0;
+}
+
+int op_meno_ma(istruzione *i)
+{
+    return 0;
+}
+

+ 14 - 0
accumulatore.h

@@ -0,0 +1,14 @@
+#ifndef ACCUMULATORE_INCLUSO
+#define ACCUMULATORE_INCLUSO
+
+int op_da(istruzione *i);
+int op_fam(istruzione *i);
+int op_aom(istruzione *i);
+int op_piu_ma(istruzione *i);
+int op_cma(istruzione *i);
+int op_ma(istruzione *i);
+int op_am(istruzione *i);
+int op_piu_am(istruzione *i);
+int op_meno_ma(istruzione *i);
+
+#endif

+ 85 - 0
algebra.c

@@ -0,0 +1,85 @@
+#include "elea_tipi.h"
+int op_ct(istruzione *i)
+{
+    return 0;
+}
+
+int op_meno_ct(istruzione *i)
+{
+    return 0;
+}
+
+int op_piu_ct(istruzione *i)
+{
+    return 0;
+}
+
+int op_cct(istruzione *i)
+{
+    return 0;
+}
+
+int op_piu_x(istruzione *i)
+{
+    return 0;
+}
+int op_meno_x(istruzione *i)
+{
+    return 0;
+}
+
+int op_ftm(istruzione *i)
+{
+    return 0;
+}
+
+int op_tom(istruzione *i)
+{
+    return 0;
+}
+
+int op_piu_ld(istruzione *i)
+{
+    return 0;
+}
+
+int op_xld(istruzione *i)
+{
+    return 0;
+}
+
+int op_piu_mt(istruzione *i)
+{
+    return 0;
+}
+
+int op_cmt(istruzione *i)
+{
+    return 0;
+}
+
+int op_mt(istruzione *i)
+{
+    return 0;
+}
+
+int op_tm(istruzione *i)
+{
+    return 0;
+}
+
+int op_xln(istruzione *i)
+{
+    return 0;
+}
+
+int op_piu_tm(istruzione *i)
+{
+    return 0;
+}
+
+int op_meno_mt(istruzione *i)
+{
+    return 0;
+}
+

+ 22 - 0
algebra.h

@@ -0,0 +1,22 @@
+#ifndef ALGEBRA_INCLUSO
+#define ALGEBRA_INCLUSO
+
+int op_ct(istruzione *i);
+int op_meno_ct(istruzione *i);
+int op_piu_ct(istruzione *i);
+int op_cct(istruzione *i);
+int op_piu_x(istruzione *i);
+int op_meno_x(istruzione *i);
+int op_ftm(istruzione *i);
+int op_tom(istruzione *i);
+int op_piu_ld(istruzione *i);
+int op_xld(istruzione *i);
+int op_piu_mt(istruzione *i);
+int op_cmt(istruzione *i);
+int op_mt(istruzione *i);
+int op_tm(istruzione *i);
+int op_xln(istruzione *i);
+int op_piu_tm(istruzione *i);
+int op_meno_mt(istruzione *i);
+#endif
+

+ 4 - 4
conf_caratteri.h

@@ -16,7 +16,7 @@
 #define CAR_PIU      5     /*  '+'  */
 #define CAR_DIESIS   6     /*  '#'  */
 #define CAR_BARRA    10     /*  '/'  */
-#define CAR_MENO     11     /*  '-'  */
+#define CAR_MENO     13     /*  '-'  */
 #define CAR_DIVISO   14     /*  '÷'  */
 /* e f = 0 1 */
 #define CAR_PHI      16     /*  'φ'  */
@@ -33,7 +33,7 @@
 #define CAR_UGUALE   21     /*  '='  */
 #define CAR_ALFA     22     /*  'α'  */
 #define CAR_PERCENTO 26     /*  '%'  */
-#define CAR_VIRGOLA  27     /*  ','  */
+#define CAR_VIRGOLA  29     /*  ','  */
 #define CAR_GAMMA    30     /*  'γ'  */
 /* e f = 1 1 */
 #define CAR_EPSILON 48     /*  'ε'  */
@@ -50,7 +50,7 @@
 #define CAR_APERTA_PARENTESI 53     /*  '('  */
 #define CAR_BETA   54     /*  'β'  */
 #define CAR_DOLLARO 58     /*  '$'  */
-#define CAR_ETA    59     /*  'η'  */
+#define CAR_ETA    61     /*  'η'  */
 #define CAR_PI     62     /*  'π'  */
 
 /* e f = 1 0 */
@@ -68,5 +68,5 @@
 #define CAR_ESCLAMATIVO 37     /*  '!'  */
 #define CAR_CHIUSA_PARENTESI 38     /*  ')'  */
 #define CAR_INTERROGATIVO 42     /*  '?'  */
-#define CAR_E_COMMERCIALE 43     /*  '&'  */
+#define CAR_E_COMMERCIALE 45     /*  '&'  */
 #define CAR_MOLTIPLICATO_PER 46     /*  '⊗'  */

+ 77 - 1
governo.c

@@ -1,9 +1,84 @@
 #include "elea_tipi.h"
 #include "governo.h"
+#include "memoria.h"
+#include "ricerca.h"
+#include "algebra.h"
+#include "accumulatore.h"
+#include "telescrivente.h"
 
 struct registri_sistema R; 
 
-static operazione *OP[64] = { };
+int op_salto(istruzione *i)
+{
+    return 0;
+}
+
+static operazione *OP[64] = { 
+    /* 0 = OP_SALTO */ op_salto,
+    /* 1 = OP_MEM   */ op_mem,
+    /* 2 = NO OP!   */ (operazione *)0,
+    /* 3 = OP_RIa   */ op_ria,
+    /* 4 = OP_-CT   */ op_meno_ct,
+    /* 5 = OP_+CT   */ op_piu_ct,
+    /* 6 = OP_CCT   */ op_cct,
+    /* 7 = OP_+MM   */ op_piu_mm,
+    /* 8 = NO OP!   */ (operazione *)0,
+    /* 9 = NO OP!   */ (operazione *)0,
+    /* 10 = OP_CMM  */ op_cmm,
+    /* 11 = OP_RIi  */ op_rii,
+    /* 12 = OP_CT   */ op_ct,
+    /* 13 = NO OP!   */ (operazione *)0,
+    /* 14 = OP_PUM  */ op_pum,
+    /* 15 = OP_-MM  */ op_meno_mm,
+    /* 16 = OP_MS   */ op_ms,
+    /* 17 = OP_DA   */ op_da,
+    /* 18 = OP_FAM  */ op_fam,
+    /* 19 = OP_AoM  */ op_aom,
+    /* 20 = NO OP!   */ (operazione *)0,
+    /* 21 = OP_+X   */ op_piu_x,
+    /* 22 = NO OP!   */ (operazione *)0,
+    /* 23 = OP_+MA  */ op_piu_ma,
+    /* 24 = OP_CMA  */ op_cma,
+    /* 25 = OP_MA   */ op_ma,
+    /* 26 = OP_CM   */ op_cm,
+    /* 27 = OP_AM   */ op_am,
+    /* 28 = NO OP!   */ (operazione *)0,
+    /* 29 = OP_-X   */ op_meno_x,
+    /* 30 = OP_+AM  */ op_piu_am,
+    /* 31 = OP_-MA  */ op_meno_ma,
+    /* 32 = NO OP!   */ (operazione *)0,
+    /* 33 = NO OP!   */ (operazione *)0,
+    /* 34 = OP_FTM   */ op_ftm,
+    /* 35 = OP_ToM   */ op_tom,
+    /* 36 = OP_+LD   */ op_piu_ld,
+    /* 37 = OP_XLD   */ op_xld,
+    /* 38 = NO OP!   */ (operazione *)0,
+    /* 39 = OP_+MT  */ op_piu_mt,
+    /* 40 = OP_CMT  */ op_cmt,
+    /* 41 = OP_MT  */ op_mt,
+    /* 42 = NO OP!   */ (operazione *)0,
+    /* 43 = OP_TM  */ op_tm,
+    /* 44 = NO OP!   */ (operazione *)0,
+    /* 45 = OP_XLN  */ op_xln,
+    /* 46 = OP_+TM  */ op_piu_tm,
+    /* 47 = OP_-MT  */ op_meno_mt,
+    /* 48 = NO OP!   */ (operazione *)0,
+    /* 49 = NO OP!   */ (operazione *)0,
+    /* 50 = NO OP!   */ (operazione *)0,
+    /* 51 = NO OP!   */ (operazione *)0,
+    /* 52 = NO OP!   */ (operazione *)0,
+    /* 53 = NO OP!   */ (operazione *)0,
+    /* 54 = NO OP!   */ (operazione *)0,
+    /* 55 = NO OP!   */ (operazione *)0,
+    /* 56 = NO OP!   */ (operazione *)0,
+    /* 57 = NO OP!   */ (operazione *)0,
+    /* 59 = NO OP!   */ (operazione *)0,
+    /* 60 = NO OP!   */ (operazione *)0,
+    /* 61 = NO OP!   */ (operazione *)0,
+    /* 62 = NO OP!   */ (operazione *)0,
+    /* 63 = NO OP!   */ (operazione *)0,
+    /* 64 = NO OP!   */ (operazione *)0
+};
 
 static booleano CanaleInternoOcc = NO;
 static booleano CanaleEsternoOcc = NO;
@@ -23,6 +98,7 @@ booleano canale_esterno_occupato(void)
 void esegui_primo_programma(void)
 {
     istruzione *i = R.I;
+    R.I += sizeof(istruzione);
     carattere F = *((carattere *)i);
     if (OP[F] != (operazione *)0) {
         (*OP[F])(i);

+ 1 - 1
governo.h

@@ -18,7 +18,7 @@ struct registri_sistema {
 
 extern struct registri_sistema R; /* Globale, definito in governo.c */
 
-typedef int(*operazione)(istruzione *I);
+typedef int(operazione)(istruzione *I);
 
 void esegui_primo_programma(void);
 

+ 27 - 0
memoria.c

@@ -0,0 +1,27 @@
+#include "elea_tipi.h"
+
+int op_mem(istruzione *i)
+{
+    return 0;
+}
+
+int op_piu_mm(istruzione *i)
+{
+    return 0;
+}
+
+int op_cmm(istruzione *i)
+{
+    return 0;
+}
+
+int op_pum(istruzione *i)
+{
+    return 0;
+}
+
+int op_meno_mm(istruzione *i)
+{
+    return 0;
+}
+

+ 9 - 0
memoria.h

@@ -0,0 +1,9 @@
+#ifndef MEMORIA_INCLUSO
+#define MEMORIA_INCLUSO
+
+int op_mem(istruzione *i);
+int op_piu_mm(istruzione *i);
+int op_cmm(istruzione *i);
+int op_pum(istruzione *i);
+int op_meno_mm(istruzione *i);
+#endif

+ 10 - 0
ricerca.c

@@ -0,0 +1,10 @@
+#include "elea_tipi.h"
+int op_ria(istruzione *i)
+{
+    return 0;
+}
+
+int op_rii(istruzione *i)
+{
+    return 0;
+}

+ 7 - 0
ricerca.h

@@ -0,0 +1,7 @@
+
+#ifndef RICERCA_INCLUSO
+#define RICERCA_INCLUSO
+int op_ria(istruzione *i);
+int op_rii(istruzione *i);
+
+#endif

+ 13 - 0
telescrivente.c

@@ -0,0 +1,13 @@
+#include "elea_tipi.h"
+
+int op_cm(istruzione *i)
+{
+    return 0;
+}
+
+int op_ms(istruzione *i)
+{
+    return 0;
+}
+
+

+ 8 - 0
telescrivente.h

@@ -0,0 +1,8 @@
+#ifndef TELESCRIVENTE_INCLUSO
+#define TELESCRIVENTE_INCLUSO
+
+int op_cm(istruzione *i);
+int op_ms(istruzione *i);
+
+#endif
+