int main ( int argc, char **argv ) { double time_spent; struct timeval tv1, tv2; #ifdef DEBUG printf("IN MAIN\n"); #endif /*Displays Help Command*/ if(argc!=MIN_REQUIRED) { help("WRONG NUMBER OF ARGUMENTS");} if(!strcmp(argv[1], "-h")){ help("HELP: ");} if(argc == 2){ checkArgs(argv[1]);} gettimeofday(&tv1, NULL); readFile(argv[1]); populateMemory(); readMemory(); gettimeofday(&tv2, NULL); /*printf("%x", 0x3f%0x10);*/ time_spent= (double)(tv2.tv_usec - tv1.tv_usec)/1000000 + (double)(tv2.tv_sec - tv1.tv_sec); printf("\n=========\n TIME REQUIRED: %.0f microseconds\n=========\n", time_spent* 1000000); #ifdef DEBUG printf("OUT OF MAIN\n"); #endif return 0; }
int main ( int argc, char **argv ) { double time_spent; struct timeval tv1, tv2; #ifdef DEBUG printf("IN MAIN\n"); #endif /*Check Arguments*/ if(argc!=MIN_REQUIRED) help("WRONG NUMBER OF ARGUMENTS"); if(!strcmp(argv[1], "-h")) help("HELP: "); if(argc == 2) checkArgs(argv[1]); /*Tracks time*/ gettimeofday(&tv1, NULL); /*Reads File and Populates Data*/ readFile( argv[1]); /*Populates Memory*/ populateMemory(); /*Runs through fetch decode execute loop*/ readMemory(); /*Tracks time*/ gettimeofday(&tv2, NULL); time_spent= (double)(tv2.tv_usec - tv1.tv_usec)/1000000 + (double)(tv2.tv_sec - tv1.tv_sec); printf("\n=========\n TIME REQUIRED: %.0f microseconds\n=========\n", time_spent* 1000000); #ifdef DEBUG printf("OUT OF MAIN\n"); #endif return 0; }
static int init_machine(struct program *program) { int ret; program->simulator = init_state; while (1 == (ret = populateMemory(program))) { prompt("Invalid file name.", "Enter the .obj file: ", program->objectfile); } return ret; }