5 /* $Id: main.c,v 2.3 1994/06/24 10:48:06 ceriel Exp $ */
25 extern char *strcpy();
27 char mess_file[64] = "int.mess"; /* name of message file */
31 int running; /* set if EM machine is running */
33 size maxstack; /* if set, max stack size */
34 size maxheap; /* if set, max heap size */
37 extern long inr; /* from log.c */
40 PRIVATE char *dflt_av[] = {"e.out", 0}; /* default arguments */
47 register int nosetjmp = 1;
48 int must_disassemble = 0;
53 /* Initialize the EM machine */
57 for (i = 1; i < argc; i++) {
58 if (*(argv[i]) == '-') {
59 switch (*(argv[i] + 1)) {
60 case 'd': /* disassembly */
63 case 'h': /* limit heap size */
64 maxheap = atol(argv[i] + 2);
66 case 'I': /* IgnMask pre-setting */
67 if (atoi(argv[i] + 2) < 16)
68 PreIgnMask = BIT(atoi(argv[i] + 2));
70 case 'm': /* messagefile name override */
71 strcpy(mess_file, argv[i] + 2);
73 case 'r': /* FRALimit override */
74 FRALimit = atoi(argv[i] + 2);
76 case 's': /* limit stack size */
77 maxstack = atol(argv[i] + 2);
79 case 't': /* switch on tallying */
82 case 'W': /* disable warning */
83 set_wmask(atoi(argv[i] + 2));
87 "%s: bad option: %s\n",
95 else if (logarg(argv[i])) {
96 /* interesting for the logging machine */
103 /* Initialize the logging machine */
108 init(argc - i, argv + i);
112 /* Text dump only? */
113 if (must_disassemble) {
115 "text segment disassembly produced; program was not run");
120 /* Analyse FLAGS word */
124 if ((FLAGS&FB_PROFILE) || (FLAGS&FB_FLOW) || (FLAGS&FB_COUNT))
135 /* Call first procedure */
136 running = 1; /* start the machine */
137 OnTrap = TR_HALT; /* default trap handling */
138 call(ENTRY, RSB_STP);
140 /* Run the machine */
144 if (must_log && inr >= log_start) {
145 /* log this instruction */
150 LOG(("@x9 PC = %lu OPCODE = %lu", PC,
151 btol(text_loc(PC)) < SECONDARY ?
153 btol(text_loc(PC)) + btol(text_loc(PC+1))
156 newPC(PC); /* just check for validity */
157 do_instr(nextPCbyte()); /* here it happens */
164 /* a signal has come in during this instruction */
165 LOG(("@t1 signal %d caught by EM machine", signalled));
170 /* entry point after a trap occurred */
184 if (ES_def == DEFINED) {
185 message("program exits with status %ld", ES);
186 close_down((int) ES);
189 message("program exits with undefined status");