// Toga Enhanced emulator // Oleg Mazonka 2010 #include #include #include #include #include #include #include using std::string; using std::vector; using std::cout; using std::cin; using std::istream; using std::ostream; using std::pair; namespace g{ int base=32, base_k, base_w; bool intio = false; bool conin = false; bool dbg = false; } class Memory { vector m; public: void add(int x){ m.push_back(x); } int operator[](int ip) const; bool invert(int a); bool empty() const { return m.empty(); } bool getbit(int a) const; }; void usage(); void setbase(); Memory readbcc(istream &is); void execute(Memory &m); string tos(int x){ std::ostringstream os; os<= ac && !g::conin ) usage(); } setbase(); string input_name("te.run"); if( input_i < ac ) input_name = av[input_i]; std::istream * in = &std::cin; std::ifstream fin; if( !g::conin ) { fin.open(input_name.c_str()); if( !fin ) { cout<<"cannot open input file '"<>i; if( !is ) break; m.add(i); } return m; } bool toglebit(Memory &m, int a); void execute(Memory &m) { int ip=0; for(;;) { if(g::dbg) cout<>s; if( !cin ) return; int x = atoi(s.c_str()); c = (char)x; return; } cin.get(c); } void output(char c) { if( g::intio ) { int x = (unsigned)(unsigned char)c; cout<