⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 buttons.c

📁 用汇编语言编程源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
  char *a;  if (stack_initialized)    return;  while (*args != '\0')    {      /* Skip leading blanks */      while (*args == ' ' || *args == '\t') args++;      /* First non-blank char */      a = args;      /* Last non-blank, non-null char */      while (*args != ' ' && *args != '\t' && *args != '\0') args++;      /* Terminate word */      if (a != args)	{	  if (*args != '\0')	    *args++ = '\0';	/* Null terminate */	  argv [argc++] = a;	}    }  initialize_run_stack (argc, argv);  stack_initialized = 1;}#ifdef __STDC__static voidrun_prompt_destroyed (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidrun_prompt_destroyed (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  run_popup = NULL;}/* *** Step *** */static char *step_size = NULL;	/* Retain step size */static Widget step_popup = NULL;static Widget step_field1_text, step_field2_text;#ifdef __STDC__static voidstep_prompt (Widget button, XtPointer client_data, XtPointer call_data)#elsestatic voidstep_prompt (button, client_data, call_data)     Widget button;     XtPointer client_data, call_data;#endif{  if (step_popup == NULL)    {      if (step_size == NULL)	step_size = str_copy ("1");      step_popup = popup_two_field_dialog (button, "step program",					  "number of steps:", step_size,					  "args:", xspim_file_name,					  "step", step_program_action,					  "continue", step_continue_action,					  &step_field1_text,					  &step_field2_text);      XtAddCallback (step_popup, XtNdestroyCallback, step_prompt_destroyed,		     (XtPointer) 0);    }  confirmAction =  step_program_action;  XtPopup (step_popup, XtGrabNone);}#ifdef __STDC__static voidstep_program_action (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidstep_program_action (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  Arg args[10];  String value1, value2;  mem_addr addr;  int steps;  XtSetArg (args[0], XtNstring, &value1);  XtGetValues (step_field1_text, args, ONE);  XtSetArg (args[0], XtNstring, &value2);  XtGetValues (step_field2_text, args, ONE);  steps = atoi (value1);  free (step_size);  step_size = str_copy (value1);  addr = starting_address ();  init_stack (value2);  if (steps > 0 && addr > 0)    execute_program (addr, steps, 1, 1);  else    error ("Cannot step %d steps from 0x%x\n", steps, addr);}#ifdef __STDC__static voidstep_continue_action (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidstep_continue_action (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  Widget dialog = (Widget) client_data;  XtPopdown (XtParent (dialog));  destroy_popup_prompt (NULL, (XtPointer) dialog, (XtPointer) NULL);  step_popup = NULL;  execute_program (PC, DEFAULT_RUN_STEPS, 0, 0);}#ifdef __STDC__static voidstep_prompt_destroyed (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidstep_prompt_destroyed (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  step_popup = NULL;}/* *** Reload *** */#ifdef __STDC__static voidadd_reload_button (Widget parent)#elsestatic voidadd_reload_button (parent)     Widget parent;#endif{  Widget command, menu, entry;  Arg args[2];  XtSetArg (args[0], XtNwidth, button_width);  command = XtCreateManagedWidget ("reload", menuButtonWidgetClass,				   parent, args, ONE);  menu = XtCreatePopupShell ("menu", simpleMenuWidgetClass, command,			     NULL, ZERO);  entry = XtCreateManagedWidget ("assembly file", smeBSBObjectClass, menu,				 args, ONE);  XtAddCallback (entry, XtNcallback, reload_action,		 (XtPointer) 1);}#ifdef __STDC__static voidreload_action (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidreload_action (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  int assem_or_exec = (int) client_data;  if (xspim_file_name == NULL)    return;  write_output (message_out, "Memory and registers cleared\n\n");  initialize_world (load_trap_handler ? trap_file : NULL);  write_startup_message ();  stack_initialized = 0;  read_file (xspim_file_name, assem_or_exec);}/* *** Clear *** */#define CLEAR_REGS 1#define CLEAR_MEM_REGS 2#define CLEAR_CONSOLE 3#ifdef __STDC__static voidadd_clear_button (Widget parent)#elsestatic voidadd_clear_button (parent)     Widget parent;#endif{  Widget command, menu, entry;  Arg args[2];  XtSetArg (args[0], XtNwidth, button_width);  command = XtCreateManagedWidget ("clear", menuButtonWidgetClass,				   parent, args, ONE);  menu = XtCreatePopupShell ("menu", simpleMenuWidgetClass, command,			     NULL, ZERO);  entry = XtCreateManagedWidget ("registers", smeBSBObjectClass, menu,				 args, ONE);  XtAddCallback (entry, XtNcallback, clear_program_state_action,		 (XtPointer) CLEAR_REGS);  entry = XtCreateManagedWidget ("memory & registers", smeBSBObjectClass, menu,				 args, ONE);  XtAddCallback (entry, XtNcallback, clear_program_state_action,		 (XtPointer) CLEAR_MEM_REGS);  entry = XtCreateManagedWidget ("console display", smeBSBObjectClass, menu,				 args, ONE);  XtAddCallback (entry, XtNcallback, clear_program_state_action,		 (XtPointer) CLEAR_CONSOLE);}#ifdef __STDC__static voidclear_program_state_action (Widget w, XtPointer client_data,			    XtPointer call_data)#elsestatic voidclear_program_state_action (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  int clear_op = (int) client_data;  switch (clear_op)    {    case CLEAR_REGS:      write_output (message_out, "Registers cleared\n\n");      initialize_registers ();      break;    case CLEAR_MEM_REGS:      write_output (message_out, "Memory and registers cleared\n\n");      initialize_world (load_trap_handler ? trap_file : NULL);      write_startup_message ();      stack_initialized = 0;      break;    case CLEAR_CONSOLE:      write_output (message_out, "Console display cleared\n\n");      clear_console_display ();      break;    default:      fatal_error("Unknown action: %d\n", clear_op);    }  redisplay_text ();  redisplay_data ();}/* *** Set Value *** */static Widget set_value_popup = NULL;static Widget set_field1_text, set_field2_text;#ifdef __STDC__static voidset_value_prompt (Widget button, XtPointer client_data, XtPointer call_data)#elsestatic voidset_value_prompt (button, client_data, call_data)     Widget button;     XtPointer client_data, call_data;#endif{  if (set_value_popup == NULL)    {      set_value_popup = popup_two_field_dialog (button, "set value",					   "register/location:", "",					   "value:", "",					   "set", parse_set_value,					   NULL, NULL,					   &set_field1_text, &set_field2_text);      XtAddCallback (set_value_popup, XtNdestroyCallback,		     set_value_destroyed, (XtPointer) 0);    }  confirmAction = parse_set_value;  XtPopup (set_value_popup, XtGrabNone);}#ifdef __STDC__static voidparse_set_value (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidparse_set_value (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  Arg args[10];  String value1, value2;  Widget form = XtParent (w);  XtSetArg (args[0], XtNstring, &value1);  XtGetValues (set_field1_text, args, ONE);  XtSetArg (args[0], XtNstring, &value2);  XtGetValues (set_field2_text, args, ONE);  destroy_popup_prompt (NULL, (XtPointer) form, NULL);  set_value_action (value1, value2);}#ifdef __STDC__static voidset_value_action (char *location_str, char *value_str)#elsestatic voidset_value_action (location_str, value_str)     char *location_str, *value_str;#endif{  unsigned long value;  int reg_no;  if (strlen (value_str) == 3      && value_str[0] == '\''      && value_str[2] == '\'')    {      /* Literal of the form: 'c' */      value = value_str[1];    }  else    {      value = strtol (value_str, NULL, 0);    }  reg_no = register_name_to_number (location_str);  if (reg_no < 0)    if (*location_str == '$' || *location_str == 'r' || *location_str == 'R')      reg_no = register_name_to_number (location_str + 1);  if (reg_no == 0)    error ("Cannot modify register 0\n");  else if (reg_no > 0)    R[reg_no] = (reg_word)value;  else if (streq (location_str, "Status") || streq (location_str, "status"))    Status_Reg = (reg_word)value;  else if (streq (location_str, "PC") || streq (location_str, "pc"))    PC = (reg_word)value;  else if (streq (location_str, "EPC") | streq (location_str, "epc"))    EPC = (reg_word)value;  else    {      char *eptr;      mem_addr addr;      /* Try to parse string as a number */      addr = strtol (location_str, &eptr, 0);      if (eptr == location_str)	error ("Unknown register selected: %s\n", location_str);      else	SET_MEM_WORD (addr, value);    }  redisplay_data ();}#ifdef __STDC__static voidset_value_destroyed (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidset_value_destroyed (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  set_value_popup = NULL;}/* *** Print *** */#ifdef __STDC__static voidadd_print_button (Widget parent)#elsestatic voidadd_print_button (parent)     Widget parent;#endif{  Widget command, menu, entry;  Arg args[2];  XtSetArg (args[0], XtNwidth, button_width);  command = XtCreateManagedWidget ("print", menuButtonWidgetClass,				   parent, args, ONE);  menu = XtCreatePopupShell ("menu", simpleMenuWidgetClass, command,			     NULL, ZERO);  entry = XtCreateManagedWidget ("memory location(s)", smeBSBObjectClass, menu,				 args, ONE);  XtAddCallback (entry, XtNcallback, print_mem_prompt, NULL);  entry = XtCreateManagedWidget ("global symbols", smeBSBObjectClass, menu,				 args, ONE);  XtAddCallback (entry, XtNcallback, print_symbol_action, NULL);}static Widget print_popup = NULL;static Widget print_field1_text, print_field2_text;#ifdef __STDC__static voidprint_mem_prompt (Widget button, XtPointer client_data, XtPointer call_data)#elsestatic voidprint_mem_prompt (button, client_data, call_data)     Widget button;     XtPointer client_data, call_data;#endif{  if (print_popup == NULL)    {      print_popup = popup_two_field_dialog (XtParent (button), "print memory",					"from", "",					"to", "",					"print", parse_print_value,					NULL, NULL,					&print_field1_text,					&print_field2_text);      XtAddCallback (print_popup, XtNdestroyCallback, print_prompt_destroyed,		     (XtPointer) 0);    }  confirmAction = parse_print_value;  XtPopup (print_popup, XtGrabNone);}#ifdef __STDC__static voidparse_print_value (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidparse_print_value (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  Arg args[10];  String value1, value2;  Widget form = XtParent (w);  XtSetArg (args[0], XtNstring, &value1);  XtGetValues (print_field1_text, args, ONE);  XtSetArg (args[0], XtNstring, &value2);  XtGetValues (print_field2_text, args, ONE);  XtPopdown (XtParent (form));  destroy_popup_prompt (NULL, (XtPointer) form, NULL);  if (!streq (value1, ""))    {      mem_addr from, to;      from = strtoul (value1, NULL, 0);      to = strtoul (value2, NULL, 0);      if (streq (value2, ""))	print_mem (from);      else	for ( ; from <= to; from+= BYTES_PER_WORD)	  print_mem (from);    }}#ifdef __STDC__static voidprint_symbol_action (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidprint_symbol_action (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  print_symbols ();}#ifdef __STDC__static voidprint_prompt_destroyed (Widget w, XtPointer client_data, XtPointer call_data)#elsestatic voidprint_prompt_destroyed (w, client_data, call_data)     Widget w;     XtPointer client_data, call_data;#endif{  print_popup = NULL;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -