Simpletron

int main(int argc, char *argv[])
{
     char command[10], filename[200];
     int load=0;
     InitSystem();
     while(1)
     {
          ShowIndicator();
          scanf("%s", command);
          if(!strcmp(command, "exit"))
               return 0;
          else if(!strcmp(command, "halt"))
               HaltSystem();
          else if(!strcmp(command, "load"))
          {
               scanf("%s", filename);
               if((load=LoadCode(filename)) == 0)
                    HandleError(-10004);
               else if(load == -1)
                    ClearMemory();
               else
                    printf("源文件%s已載入\n", filename);
          }
          else if(!strcmp(command, "run"))
               if(load)
               {
                    printf("正在運行源文件%s\n", filename);
                    puts("提示符?代表程序要求鍵盤輸入");
                    puts("---------------------------------");
                    RunCode();
                    puts("---------------------------------");
               }
               else
                    HandleError(-10003);
          else if(!strcmp(command, "view"))
               if(load)
                    ViewCode(filename);
               else
                    HandleError(-10003);
          else if(!strcmp(command, "clear"))
               system("cls");
          else if(!strcmp(command, "help"))
               ShowHelp();
          else
               puts("無效的指令");
     }
     return 0;
}


int InitSystem(void);
int ShowHelp(void);
int InitSystem(void);
int ShowIndicator(void);
int ClearMemory(void);
int LoadCode(char *);
int RunCode(void);
int ProcessLine(int code);
int HaltSystem(void);
int ViewCode(void);
int SMLRead(int);
int SMLWrite(int);
int SMLLoad(int);
int SMLStore(int);
int SMLAdd(int);
int SMLSubstract(int);
int SMLDivide(int);
int SMLMultiply(int);
int SMLBranch(int);
int SMLBranchNegative(int);
int SMLBranchZero(int);
int IsLegal(int codeline);
int HandleError(void);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章