OSDN Git Service

modified: Makefile
authorTakuo Yasunaga <yasunaga@bio.kyutech.ac.jp>
Tue, 27 May 2014 19:42:56 +0000 (04:42 +0900)
committerTakuo Yasunaga <yasunaga@bio.kyutech.ac.jp>
Tue, 27 May 2014 19:42:56 +0000 (04:42 +0900)
modified:   computer-m
new file:   computer-m-exec.c
new file:   computer-m-read.c
modified:   computer-m.c
modified:   computer-m.h
new file:   test/Makefile

Makefile
computer-m
computer-m-exec.c [new file with mode: 0644]
computer-m-exec.o [new file with mode: 0644]
computer-m-read.c [new file with mode: 0644]
computer-m-read.o [new file with mode: 0644]
computer-m.c
computer-m.h
computer-m.o
test/Makefile [new file with mode: 0644]

index 4fddbc4..7ae6ab1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,8 @@
-computer-m: computer-m.o
-       cc -o computer-m computer-m.o 
+computer-m: computer-m.o computer-m-read.o computer-m-exec.o
+       cc -o computer-m computer-m.o computer-m-read.o computer-m-exec.o
+
+test:
+       cd test; make 
 
 clean:
-       rm *.o
+       rm *.o computer-m
index 2a17df5..38ecf85 100755 (executable)
Binary files a/computer-m and b/computer-m differ
diff --git a/computer-m-exec.c b/computer-m-exec.c
new file mode 100644 (file)
index 0000000..0b5bab4
--- /dev/null
@@ -0,0 +1,7 @@
+#include "./computer-m.h"
+
+void
+comm_Exec(Computer_m* comp, int mode)
+{
+
+}
diff --git a/computer-m-exec.o b/computer-m-exec.o
new file mode 100644 (file)
index 0000000..c965152
Binary files /dev/null and b/computer-m-exec.o differ
diff --git a/computer-m-read.c b/computer-m-read.c
new file mode 100644 (file)
index 0000000..db80b2b
--- /dev/null
@@ -0,0 +1,7 @@
+#include "./computer-m.h"
+
+void
+comm_Read(Computer_m* comp, int mode)
+{
+
+}
diff --git a/computer-m-read.o b/computer-m-read.o
new file mode 100644 (file)
index 0000000..4c80e06
Binary files /dev/null and b/computer-m-read.o differ
index b110e3a..33ecd84 100644 (file)
@@ -1,4 +1,10 @@
+/*
+* Computer-m
+*   by tacyas
+*/
+
 #include <stdio.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include "./computer-m.h"
 
@@ -11,23 +17,54 @@ main(int argc, char* argv[])
        Computer_m comp;
 
        argCheck(&comp, argc, argv);
+
+       comm_Read(&comp, 0);
+       comm_Exec(&comp, 0);
+
+       return 0;
 }
 
 int
 argCheck(Computer_m* comp, int argc, char* argv[]) 
 {
        int result;
-       while((result=getopt(argc, argv, "hi:o:p:c:"))!=-1) {
+       while((result=getopt(argc, argv, "hi:o:p:l:"))!=-1) {
                switch(result) {
                        case 'h': 
                                usage(stderr);
                                break;
-                       case 'i': 
-                       case 'o': 
-                       case 'p': 
-                       case 'c': 
-                               fprintf(stderr, "%c %s\n", result, optarg); 
+                       case 'i': { 
+                               comp->inputDevice = fopen(optarg, "r");
+                               if(NULL!=comp->inputDevice) {
+                                       fprintf(stderr, "Cannot open as inputDevice: %s\n", optarg);
+                                       usage(stderr);
+                               }
+                               break;
+                       }
+                       case 'o': {
+                               comp->outputDevice = fopen(optarg, "a");
+                               if(NULL!=comp->outputDevice) {
+                                       fprintf(stderr, "Cannot open as outputDevice: %s\n", optarg);
+                                       usage(stderr);
+                               }
+                               break;
+                       }
+                       case 'p': {
+                               comp->programList = fopen(optarg, "r");
+                               if(NULL!=comp->programList) {
+                                       fprintf(stderr, "Cannot open as programList: %s\n", optarg);
+                                       usage(stderr);
+                               }
                                break;
+                       }
+                       case 'l': {
+                               comp->logDevice = fopen(optarg, "a");
+                               if(NULL!=comp->logDevice) {
+                                       fprintf(stderr, "Cannot open as logDevice: %s\n", optarg);
+                                       usage(stderr);
+                               }
+                               break;
+                       }
                        case ':': 
                                fprintf(stderr, "%c needs value\n", result); 
                                break;  
@@ -36,14 +73,30 @@ argCheck(Computer_m* comp, int argc, char* argv[])
                                break;
                }
        }
-
+       return 0;
 }
 
 int
 usage(FILE* fpt)
 {
-       fprintf(stderr, "-i filename or stdin\n");
-       fprintf(stderr, "-o filename or stdout\n");
-       fprintf(stderr, "-p filename \n");
+       fprintf(fpt, "-i inputFilename(RSEND)  or stdin \n");
+       fprintf(fpt, "-o outputFilename(ASEND) or stdout \n");
+       fprintf(fpt, "-p program-data-List\n");
+       fprintf(fpt, "-l logfile or stderr \n");
+
+       fprintf(fpt, ">>>> program-data-list Format\n");
+       fprintf(fpt, "PC:  InitPC\n");
+       fprintf(fpt, "CCR: InitCCR\n");
+       fprintf(fpt, "[ReadyQueue: program-ID0 PC0 IR0 CCR0]\n");
+       fprintf(fpt, "[....]\n");
+       fprintf(fpt, "ID: program-ID0\n");
+       fprintf(fpt, "MMU: Address Instruction_Or_Data\n");
+       fprintf(fpt, "MMU: ....\n");
+       fprintf(fpt, "[ID: program-ID1]\n");
+       fprintf(fpt, "[MMU: ....]\n");
+
+       exit(EXIT_FAILURE);
+       return 0;       
 }
 
+
index 521fe4d..189441e 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef COMPUTER_M_H
 #define COMPUTER_M_H
 
+/*
+       computer-m
+*/
+
 #include <stdio.h>
 
 #define MAX_INSTRUCTION (512) 
 typedef enum __Computer_m_Instruction {
        CmI_ADD=0,
        CmI_SUB=1,
-       CmI_GT =2,
-       CmI_EQUAL=3,
-       CmI_JUMP=4,
-       CmI_JOT=5,
-       CmI_JOF=6,
-       CmI_HALT=7
+       CmI_MUL=2,
+       CmI_DIV=3,
+       CmI_MOV=4,
+       CmI_EQUAL=5,
+       CmI_GT =6,
+       CmI_GE =7,
+       CmI_JUMP=8,
+       CmI_JOT=9,
+       CmI_JOF=10,
+       CmI_HALT=11,
+       CmI_SEND=12,
+       CmI_RSEND=13,
+       CmI_ASEND=14,
+       CmI_REC=15,
+       CmI_RREC=16,
+       CmI_AREC=17
 } Computer_m_Instruction;
 
 typedef struct __Computer_m_CPU  {
@@ -26,14 +40,19 @@ typedef struct __Computer_m_CPU  {
 typedef char* Computer_m_CELL;
 
 typedef struct __Computer_m_MMU {
-       char Cell[MEMSIZE];
+       char* Cell[MEMSIZE];
 } Computer_m_MMU;
 
 typedef struct __Computer_m {
        FILE* inputDevice;
        FILE* outputDevice;
+       FILE* programList;
+       FILE* logDevice;
        Computer_m_CPU CPU;
        Computer_m_MMU MMU;
 } Computer_m;
 
+extern void comm_Read(Computer_m* comp, int mode);
+extern void comm_Exec(Computer_m* comp, int mode);
+
 #endif
index c4ec991..dc080af 100644 (file)
Binary files a/computer-m.o and b/computer-m.o differ
diff --git a/test/Makefile b/test/Makefile
new file mode 100644 (file)
index 0000000..f7a7a4c
--- /dev/null
@@ -0,0 +1,5 @@
+all:help
+
+help:
+       ../computer-m -h
+