int main (int argc, char **argv) { int o; int save_trace; bfd *prog; #ifdef HAVE_networking char *console_port_s = 0; #endif setbuf (stdout, 0); in_gdb = 0; while ((o = getopt (argc, argv, "tc:vdm:C")) != -1) switch (o) { case 't': trace++; break; case 'c': #ifdef HAVE_networking console_port_s = optarg; #else fprintf (stderr, "Nework console not available in this build.\n"); #endif break; case 'C': #ifdef HAVE_TERMIOS_H m32c_use_raw_console = 1; #else fprintf (stderr, "Raw console not available in this build.\n"); #endif break; case 'v': verbose++; break; case 'd': m32c_disassemble++; break; case 'm': if (strcmp (optarg, "r8c") == 0 || strcmp (optarg, "m16c") == 0) default_machine = bfd_mach_m16c; else if (strcmp (optarg, "m32cm") == 0 || strcmp (optarg, "m32c") == 0) default_machine = bfd_mach_m32c; else { fprintf (stderr, "Invalid machine: %s\n", optarg); exit (1); } break; case '?': fprintf (stderr, "usage: run [-v] [-C] [-c port] [-t] [-d] [-m r8c|m16c|m32cm|m32c]" " program\n"); exit (1); } prog = bfd_openr (argv[optind], 0); if (!prog) { fprintf (stderr, "Can't read %s\n", argv[optind]); exit (1); } if (!bfd_check_format (prog, bfd_object)) { fprintf (stderr, "%s not a m32c program\n", argv[optind]); exit (1); } save_trace = trace; trace = 0; m32c_load (prog); trace = save_trace; #ifdef HAVE_networking if (console_port_s) setup_tcp_console (console_port_s); #endif sim_disasm_init (prog); while (1) { int rc; if (trace) printf ("\n"); if (m32c_disassemble) sim_disasm_one (); enable_counting = verbose; cycles++; rc = decode_opcode (); enable_counting = 0; if (M32C_HIT_BREAK (rc)) done (1); else if (M32C_EXITED (rc)) done (M32C_EXIT_STATUS (rc)); else assert (M32C_STEPPED (rc)); trace_register_changes (); #ifdef TIMER_A update_timer_a (); #endif } }
int main (int argc, char **argv) { int o; int save_trace; bfd *prog; while ((o = getopt (argc, argv, "tvdm:")) != -1) switch (o) { case 't': trace++; break; case 'v': verbose++; break; case 'd': disassemble++; break; case 'm': if (strcmp (optarg, "r8c") == 0 || strcmp (optarg, "m16c") == 0) default_machine = bfd_mach_m16c; else if (strcmp (optarg, "m32cm") == 0 || strcmp (optarg, "m32c") == 0) default_machine = bfd_mach_m32c; else { fprintf (stderr, "Invalid machine: %s\n", optarg); exit (1); } break; case '?': fprintf (stderr, "usage: run [-v] [-t] [-d] [-m r8c|m16c|m32cm|m32c]" " program\n"); exit (1); } prog = bfd_openr (argv[optind], 0); if (!prog) { fprintf (stderr, "Can't read %s\n", argv[optind]); exit (1); } if (!bfd_check_format (prog, bfd_object)) { fprintf (stderr, "%s not a m32c program\n", argv[optind]); exit (1); } save_trace = trace; trace = 0; m32c_load (prog); trace = save_trace; if (disassemble) sim_disasm_init (prog); while (1) { int rc; if (trace) printf ("\n"); if (disassemble) sim_disasm_one (); enable_counting = verbose; cycles++; rc = decode_opcode (); enable_counting = 0; if (M32C_HIT_BREAK (rc)) done (1); else if (M32C_EXITED (rc)) done (M32C_EXIT_STATUS (rc)); else assert (M32C_STEPPED (rc)); trace_register_changes (); } }