示例#1
0
文件: main.c 项目: alexleigh/sys161
/*
 * This is its own function because it's called from the gdb support
 * to single-step. We only bill time if cpu_cycle reports it actually
 * did something. (Which it always does, except if it hits a builtin
 * breakpoint. It's essential to make the builtin breakpoints
 * completely transparent, even to the extent of not wasting a single
 * cycle, so it's possible to debug those race conditions where
 * there's a two-instruction window for an interrupt to cause a crash.
 */
inline
void
onecycle(void)
{
	if (cpu_cycle()) {
		clock_tick();
	}
}
示例#2
0
文件: main.c 项目: JMarlin/speedrun
int main(int argc, char* argv[]) {

    int done;
    deviceEntry* gpu;
    ramBlock* mainRAM;
    romBlock* monitorROM;
    interfaceChip* userInterface;

    //Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );
    SDL_ShowCursor( SDL_DISABLE );
    atexit(SDL_Quit);
    printf("SDL started.\n");

    gpu = gpu_create(0xFC00);
    if(gpu == NULL)
      return 0;
    mainRAM = ram_create(0x1000, 0xF7FF);
    monitorROM = rom_create(0x0000, 0x0FFF, "monitor.rom");
    userInterface = interface_create(0xFFFE);

    cpu_addDevice(mainRAM->device);
    cpu_addDevice(monitorROM->device);
    cpu_addDevice(gpu);
    cpu_addDevice(userInterface->device);

    cpu_reset();

    while(cpu_cycle(2000)){

        interface_pollKeyboard();
        gpu_redraw(); //<- this is slowing execution down a lot. We should really put it on a 30-60hz timer.

    }
    gpu_redraw();

    printf("CPU halted.", "Notice");

    ram_unload();
    rom_unload();
    interface_unload();
    gpu_unload();
    cpu_unloadDevices();

    SDL_Quit();

    return 0;

}
示例#3
0
int main(int argc, char **argv) {
  int i;

  ram_init();
  cpu_reset();
  load_rom("microwriter.rom");
  
  for (i = 0; i < 10000; i++) {
    cpu_cycle();
  }

  printf("Done.\n");
  ram_free();

  return 0;
}
示例#4
0
文件: main.c 项目: thebirk/ccpu
int cpu_thread_func(void* args)
{
	FILE* f;	

	while(cpu_running) {
		if(stepping) {			
			printf("IP: 0x%04X, ADDRESS: 0x%04X\n", c->ip, c->address);
			printf("ACC: 0x%02X, X: 0x%02X, Y: 0x%02X\n", c->acc, c->x, c->y);
			printf("HLT: %s\n", c->hlt ? "true" : "false");
			
get_input:
			printf(": ");
			char in = getchar();
			switch (in) {
				case 'x':
				case 'X':
				case 'q':
				case 'Q':
					cpu_running = 0;
					return 0;
					break;
				case 'd':
				case 'D':
					f = fopen("memdump.bin", "wb");
					fwrite(c->mem, sizeof(u8), 0x10000, f);
					fclose(f);
					goto get_input;
					break;
			}
		}
		if(c->hlt) { 
			cpu_running = 0;
			return 0;
		}		

		cpu_cycle(c);
	}


	return 0;
}
示例#5
0
int main(int argc, char **argv) {

    if(argc < 2) {
        printf("Especifique o arquivo com o codigo\n");
        exit(0);
    }

    init_memory();

    init_stack();

    loadcode(argv[1]);

    init_cpu();

    while(cpu_cycle());

    memory_dump();

    free_memory();
    return 0;
}