예제 #1
0
파일: main.c 프로젝트: Yhgenomics/bgt
int main(int argc, char *argv[])
{
	if (argc < 2) return usage();
	if (strcmp(argv[1], "import") == 0) return main_import(argc-1, argv+1);
	else if (strcmp(argv[1], "view") == 0 || strcmp(argv[1], "mview") == 0 ) return main_view(argc-1, argv+1);
	else if (strcmp(argv[1], "fmf") == 0 ) return main_fmf(argc-1, argv+1);
	else if (strcmp(argv[1], "getalt") == 0) return main_getalt(argc-1, argv+1);
	else if (strcmp(argv[1], "bcfidx") == 0) return main_bcfidx(argc-1, argv+1);
	else if (strcmp(argv[1], "version") == 0) {
		puts(BGT_VERSION);
		return 0;
	} else {
		fprintf(stderr, "[E::%s] unrecognized command '%s'\n", __func__, argv[1]);
		return 1;
	}
}
예제 #2
0
static void run_machine(struct program *program)
{
        bool simulating = true;
        enum STATE currentState = MAIN;

        outputHeight = (uint16_t) (2 * (LINES - 6) / 3 - 2);
        memoryOutput = malloc(sizeof(uint16_t) * outputHeight);
        if (NULL == memoryOutput) {
                perror("LC3-Simulator");
                exit(EXIT_FAILURE);
        }

        generateContext(context, program, 0, program->simulator.PC);

        while (simulating) {
                set_state(&currentState);

                switch (currentState) {
                case MAIN:
                        simulating = main_view(status, &currentState, program);
                        break;
                case SIM:
                        simulating = simulator_view(output, status, program,
                                &currentState);
                        break;
                case MEM:
                        if (-1 == memPopulated) {
                                generateContext(context, program, 0,
                                        program->simulator.PC);
                        } else {
                                generateContext(context, program, selected,
                                        (uint16_t) memPopulated);
                        }
                        simulating = memory_view(context, program, &currentState);
                        break;
                default:
                        break;
                }
        }

        free(memoryOutput);
        memoryOutput = NULL;
}