Esempio n. 1
0
void memsize(int size)
{
	memory = make_memory(size);
}
Esempio n. 2
0
void
initialize_world (int context, char *exception_file_paths, char *exception_file_name)
{
  reg_image_t &reg_image = reg_images[context];
  reg_image.context = context;
  reg_image.auto_alignment = 1;

  /* Allocate the floating point registers */
  if (reg_image.FGR == NULL)
    reg_image.FPR = (double *) xmalloc (FPR_LENGTH * sizeof (double));
  /* Allocate the memory */
  make_memory (context,
	       initial_text_size,
	       initial_data_size, initial_data_limit,
	       initial_stack_size, initial_stack_limit,
	       initial_k_text_size,
	       initial_k_data_size, initial_k_data_limit);
  initialize_registers (context);
  initialize_inst_tables ();
  initialize_symbol_table ();
  k_text_begins_at_point (context, K_TEXT_BOT);
  k_data_begins_at_point (context, K_DATA_BOT);
  data_begins_at_point (context, DATA_BOT);
  text_begins_at_point (context, TEXT_BOT);

  if (exception_file_paths != NULL)
    {
      bool old_bare = bare_machine;
      bool old_accept = accept_pseudo_insts;
      char *filename;
      char *files;

      /* Save machine state */
      bare_machine = false;     /* Exception handler uses extended machine */
      accept_pseudo_insts = true;

      /* strtok modifies the string, so we must back up the string prior to use. */
      if ((files = strdup (exception_file_paths)) == NULL)
         fatal_error ("Insufficient memory to complete.\n");

      for (filename = strtok (files, ";"); filename != NULL; filename = strtok (NULL, ";"))
         {
            /* if you pass in non-NULL second parameter, I assume one exception file */
            if (!read_assembly_file (context, filename, exception_file_name))
               fatal_error ("Cannot read exception handler: %s\n", filename);

            write_output (message_out, "Loaded: %s\n", filename);
         }

      free (files);

      /* Restore machine state */
      bare_machine = old_bare;
      accept_pseudo_insts = old_accept;

      if (!bare_machine)
      {
        (void)make_label_global ("main"); /* In case .globl main forgotten */
        (void)record_label ("main", 0, 0);
      }
    }
  initialize_scanner (stdin, "");
  delete_all_breakpoints ();
}