本文整理汇总了C++中Stack::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ Stack::Init方法的具体用法?C++ Stack::Init怎么用?C++ Stack::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack::Init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc , char *argv[])
{
// Setting the Flag lookup table /* May have to take this from user ..... check later */
flag_lookup["u"] ="000";
flag_lookup["z"] ="001";
flag_lookup["nz"] ="010";
flag_lookup["p"] ="011";
flag_lookup["m"] ="100";
flag_lookup["c"] ="101";
flag_lookup["nc"] ="110";
flag_lookup["op"] ="111";
// Flag lookup table completed
// Feeding the first three locations of MicroProgram Memory /*HAS TO BE USER FED */
// 00000000001111111111222222222233333333334
// 01234567890123456789012345678901234567890
MPM.Addr_MS[0] = "00000000000000000000000000000010010000000";
MPM.Addr_MS[1] = "00000000000000000000000001000001000110000";
MPM.Addr_MS[2] = "00000000000000000000000100000000000000000";
// Scanning of User's instruction set is done by a different module
bool ret = Scan_init(MPM,ALU1,RG,Mem);
if (ret == false )
{
cout << "\nProblem in scanning the design file. Please correct the file and try again\n";
return -1 ;// Problem in scanning
}
// Scanning of User's input program file is done by a different module
char ch = 'n';
if (errno)
{
perror ("Pre-execution error ");
return -1;
}
while ( TRUE )
{
MS.clear();
labels.clear();
label_lookup.clear();
breaks.clear();
ret = Scan_input(Mem,ALU1,RG);
if (ret == false)
{
cout << "\nProblem with the user program file. Please correct the file and try again.\n";
return -1 ;
}
// NEW ADDED - Date 16th Nov 2009
// Scaning a memory input file from the user
if ( false == Mem.FillMemory())
{
return -1;
}
// Initializing Modules
PC.Init("00000000"); /* Change */
SP.Init();
// Modules initialized
if (errno)
{
perror ("Input file error ");
return -1;
}
// Initializing Databus
strcpy(DB.DATA,"");
DB.FLAG = FREE;
// Initial Memory Map
cout << "\tDo you want to print the initial contents of Memory and Registers ? [y/n] : ";
cin >> ch;
if (ch == 'y')
Disp.InitialMap(Mem,RG,PC,AC,OP,SP);
// Execution of Program
bool val = EXECUTE(0);
if (errno)
{
perror("Error in execution ");
break;
}
// Final Memory Map
cout << "\tDo you want to print the final contents of Memory and Registers [y/n]? : ";
cin >> ch;
if (ch == 'y')
Disp.FinalMap(Mem,RG,PC,AC,OP,SP);
cout << "\n\tTotal number of clock cycles taken to run the program :\t"<<clocks<<"\n\n";
cout << "\n\tDo you want to run another program [y/n] ? :";
cin >> ch;
if (ch !='y')
//.........这里部分代码省略.........