/* * dlxrun.c * $Id: dlxrun.c,v 1.3 2003/11/09 13:18:21 mah Exp $ * Christoph Berg * * 011220 */ #include #include #include #include #include #include #include "dlx.h" #include "help.h" #include "hex.h" #include "memory.h" #include "terminal.h" #define VERSION "v4.0alpha" // ^C handling -------- int sigint; void sigint_handler() { sigint = 1; } // -------------------- void check_machine() { /* * If any of these checks fail: this program was written for the x86 * architecture (little endian, 4 bytes integers). If you are going to * run it on a different architecture, you probably have to change (at * least) the memory referencing code (that is, (int *) casts). * You will also have to look at the include files and the endian * conversion in hex.c */ char p[] = "1234"; assert(*(int *)p == 0x34333231); // check for little endian assert(sizeof(int) == 4); // check for integer size 32 bit } int main(int argc, char **argv) { printf("dlxrun " VERSION " (" __DATE__ ")\n"); check_machine(); init_state(); state.stopmask = STOP_TRAP_EXIT; // only stop for exit init_memory(INIT_MEMORY_SIZE); if(argc != 2) { printf("Usage: %s file\n", argv[0]); } load_file(argv[1]); do { step(); } while (!state.stopflag); return 0; // TODO make it return correct exit code }