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);

本文出自 “波与粒的境界” 博客,谢绝转载!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值