#include "const.h" #include "cpu.h" #include "memory.h" #include "io.h" #include "opcodes.h" int main( int argc, char *argv[] ) { Cpu cpu; Memory memory; int retcode; if( argc != 2 ) { print( "USAGE: miniemu " ); return 1; } memory_init( &memory, DEFAULT_MEMORY_SIZE ); cpu_init( &cpu, &memory ); print( "EMULATOR STARTED" ); print( "LOADING MEMORY DUMP" ); memory_read_from_file( &memory, argv[1] ); cpu_debug( &cpu, 1 ); while( !cpu_stopped( &cpu ) ) { print( "CPU" ); cpu_print_dump( &cpu ); print( "MEMORY" ); memory_print_dump( &memory ); cpu_step( &cpu ); } retcode = cpu_has_errors( &cpu ); print( "CPU" ); cpu_print_dump( &cpu ); print( "MEMORY" ); memory_print_dump( &memory ); cpu_done( &cpu ); memory_done( &memory ); print( "EMULATOR TERMINATED" ); return retcode; }