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

📄 intlist.e

📁 A Programmer s Reference to BIOS, DOS, and Third-Party Calls
💻 E
📖 第 1 页 / 共 4 页
字号:
   insert('\n') ;
}

/*=============================================================*/
/*=============================================================*/

void insert_table_counter()
{
   char counter[6] ;
   save_var point = *table_counter + 4 ;

   /* increment that table counter */
   while (curchar() >= '0')
      {
      if (curchar() < '9')
	 {
	 replace(point,curchar()+1) ;
	 break ;
	 }
      else
	 {
	 replace(point,'0') ;
	 point-- ;
	 }
      }
   restore_vars() ;
   /* and now insert the incremented value at point */
   stuff("(Table ") ;
   grab(*table_counter,*table_counter+5,counter) ;
   stuff(counter) ;
   stuff(")") ;
}

/*=============================================================*/
/* type the name of a structure, then invoke this function     */
/* to create the "Format of X:" and "Offset Size Descr" lines  */
/*=============================================================*/

command structure_header() on intlist_tab[FCTRL(11)]
{
   int start = point ;

   to_begin_line() ;
   if (parse_string(1,str_format_of,NULL) == 0)
      {
      stuff(str_format_of) ;
      to_end_line() ;
      stuff(":\nOffset\tSize\tDescription\t") ;
      insert_table_counter() ;
      stuff("\n 00h\t") ;
      }
   else
      point = start ;
}

/*=============================================================*/
/* Turn the current line into the header for a "Values of"     */
/* section						       */
/*=============================================================*/

command value_header() on intlist_tab[FSHIFT(11)]
{
   int start = point ;
   
   to_begin_line() ;
   if (parse_string(1,"Values for ",NULL) == 0)
      {
      insert_table_counter() ;
      stuff("\nValues for ") ;
      to_end_line() ;
      stuff(":\n ") ;
      }
   else
      point = start ;
}

/*=============================================================*/
/* Turn the current line into the header of a "Call with"      */
/* section						       */
/*=============================================================*/

command call_with_header() on intlist_tab[FALT(11)]
{
   int start = point ;
   
   to_begin_line() ;
   if (parse_string(1,"Call ",NULL) == 0)
      {
      insert_table_counter() ;
      stuff("\nCall ") ;
      to_end_line() ;
      if (character(point-1) != ' ')
	 stuff(" ") ;
      stuff("with:\n") ;
      }
   else
      point = start ;
}

/*=============================================================*/
/* Turn the current line into the header of a "Bitfield for"   */
/* section						       */
/*=============================================================*/

command bitfields_for_header() on intlist_tab[FALT(12)]
{
   int start = point ;
   
   to_begin_line() ;
   if (parse_string(1,str_bitfields_for,NULL) == 0)
      {
      stuff(str_bitfields_for) ;
      to_end_line() ;
      stuff(":\nBit(s)\tDescription\t") ;
      insert_table_counter() ;
      stuff("\n ") ;
      }
   else
      point = start ;
}

/*=============================================================*/
/*=============================================================*/

char grab_int_entry_number(func_num)
char *func_num ;
{
   int i ;
   char c ;
   
   point += 4 ;				/* skip the "INT " */
   func_num[0] = curchar() ;		/* grab the interrupt number */
   point++ ;
   func_num[1] = curchar() ;
   nl_forward() ;			/* skip to second line of entry */
   if (parse_string(1,"[ \t]*A[LHX][ \t]=[ \t][0-9A-F][0-9A-F]+h",NULL))
      {
      re_search(1,"[ \t]*A") ;
      c = curchar() ;
      point += 4 ;			/* skip ch and " = " */
      if (c != 'L')
	 {
	 grab(point,point+((c=='X')?4:2),func_num+2) ;
	 point += ((c=='X')?4:2) ;
	 func_num[(c=='H')?4:6] = '-' ;	/* grab() stuck a NUL into the string */
	 }
      else /* c == 'L' */
	 {
	 func_num[4] = curchar() ;
	 point++ ;
	 func_num[5] = curchar() ;
	 point ++ ;
	 }
      point++ ;
      if (parse_string(1,"[ \t]*subfn [0-9A-F][0-9A-F]+h",NULL))
	 {
	 re_search(1,"[ \t]*subfn ") ;
	 func_num[6] = 'S' ;
	 func_num[7] = 'F' ;
	 for (i = 0 ; i < 4 ; i++)
	    {
	    c = curchar() ;
	    if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F'))
	       {
	       func_num[8+i] = c ;
	       point++ ;
	       }
	    else
	       break ;
	    }
	 }
      nl_forward() ;			/* skip to third line of entry */
      }
   if (parse_string(1,"[ \t]*([BCDES][HILPSX]|VxD) = [0-9A-F][0-9A-F]+h",NULL))
      {
      re_search(1,"[ \t]*") ;
      func_num[6] = curchar() ;
      point++ ;
      func_num[7] = c = curchar() ;
      point += 4 ;			/* skip curchar and " = " */
      if (func_num[6] == 'V')		/* VxD has three letters not two... */
	 point++ ;
      if (c == 'H' || c == 'L')
	 {
	 grab(point,point+2,func_num+8) ;
	 func_num[10] = '-' ;		/* grab() stuck a NUL into the string */
	 }
      else /* c == 'X' || c == 'I' || c == 'P' || c == 'S' */
	 {
	 grab(point,point+4,func_num+8) ;
	 func_num[12] = '-' ;
	 }
      }
   return 1 ;				/* successful and have func number */
}

/*=============================================================*/

char grab_cmos_entry_number(func_num)
char *func_num ;
{
   point += 5 ;			        /* skip the "CMOS " */
   func_num[0] = 'R' ;			/* mark this as a CMOS RAM entry */
   grab(point,point+4,func_num+1) ;
   if (func_num[3] == 'h' && func_num[4] == '-')
      grab(point+4,point+6,func_num+3) ;
   else
      {
      func_num[3] = '-' ;
      func_num[4] = '-' ;
      }
   func_num[5] = '-' ;			/* grab() stuck a NUL into string */
   return 1 ;
}

/*=============================================================*/

char grab_farcall_entry_number(func_num)
char *func_num ;
{
   point += 5 ;				/* skip the "CALL " */
   func_num[0] = '@' ;			/* mark this as a far call entry */
   grab(point,point+4,func_num+1) ;	/* get segment of address */
   grab(point+6,point+10,func_num+5) ;	/* get offset of address */
   func_num[9] = '-' ;			/* grab() stuck a NUL into string */
   return 1 ;
}

/*=============================================================*/

char grab_msr_entry_number(func_num)
char *func_num ;
{
   point += 4 ;				/* skip the "MSR " */
   func_num[0] = 'S' ;			/* mark this as an MSR entry */
   grab(point,point+8,func_num+1) ;     /* get the MSR number */
   func_num[9] = '-' ;	      		/* grab() stuck a NUL into string */
   return 1 ;
}

/*=============================================================*/

char grab_memory_entry_number(func_num)
char *func_num ;
{
   point += 4 ;				/* skip the "MEM " */
   func_num[0] = 'M' ;		        /* mark this as a memory loc entry */
   grab(point,point+6,func_num+1) ;	/* get segment or high word of addr */
   if (func_num[5] == 'h' && func_num[6] == ':') /* segmented address? */
      grab(point+6,point+10,func_num+5) ;	/* get offset of address */
   else
      {
      grab(point+6,point+8,func_num+7) ;/* get low word of the address */
      func_num[0] = 'm' ;		/* indicate linear address */
      }
   func_num[9] = '-' ;			/* grab() stuck a NUL into string */
   return 1 ;
}

/*=============================================================*/

char grab_opcode_name(func_num)
char *func_num ;
{
   int i ;
   point += 7 ;				/* skip the "OPCODE " */
   func_num[0] = 'O' ;			/* mark this as an opcode entry */
   for (i = 2 ; i < 12 ; i++)		/* grab the opcode name and stuff */
      {			   		/*   it into the header line */
      char c = curchar() ;
      if (c == ' ' || c == '\t')
	 break ;
      else
	 {
	 func_num[i] = c ;
	 point++ ;
	 }
      }
   return 1 ;
}

/*=============================================================*/

char grab_port_entry_number(func_num)
char *func_num ;
{
   point += 5 ;				/* skip the "PORT " */
   func_num[0] = 'P' ;			/* mark this as an I/O port entry */
   grab(point,point+4,func_num+1) ;	/* get starting port number */
   func_num[5] = '-' ;			/* grab() stuck a NUL into string */
   if (character(point+4) == '-')
      {
      grab(point+5,point+9,func_num+5) ; /* get ending port number */
      func_num[9] = '-' ;		/* grab() stuck a NUL into string */
      }
   return 1 ;
}

/*=============================================================*/

char grab_i2c_entry_number(func_num)
char *func_num ;
{
   point += 4 ;				/* skip the "I2C " */
   func_num[0] = 'I' ;			/* mark this as an I2C port entry */
   grab(point,point+2,func_num+1) ;	/* get slave address */
   func_num[3] = '-' ;			/* grab() stuck a NUL into string */
   if (character(point+3) == '/')
      {
      grab(point+4,point+6,func_num+3) ; /* get register address */
      func_num[5] = '-' ;		/* grab() stuck a NUL into string */
      if (character(point+6) != 'h' && character(point+6) != '/')
	 {
	 grab(point+6,point+8,func_num+5) ; /* get second byte of reg. addr */
	 func_num[7] = '-' ;		/* grab() stuck a NUL into string */
	 point += 2 ;
	 }
      if (character(point+7) == '/')
	 {
	 func_num[7] = 'S' ;
	 func_num[8] = 'F' ;
	 grab(point+8,point+10,func_num+9) ;
	 func_num[11] = '-' ;
	 if (character(point+10) != 'h')
	    grab(point+10,point+12,func_num+11) ;
	 }
      }
   return 1 ;
}

/*=============================================================*/

char grab_entry_number(func_num)
char *func_num ;
{
   strcpy(func_num,"-------------") ;	/* 13 dashes */
   point++ ;				/* go to first char of separator line */
   nl_forward() ;			/* go to first line of entry */
   if (parse_string(1,"INT ",NULL))	/* is it an interrupt entry? */
      return grab_int_entry_number(func_num) ;
   else if (parse_string(1,"CMOS ",NULL) != 0)
      return grab_cmos_entry_number(func_num) ;
   else if (parse_string(1,"CALL ",NULL) != 0)
      return grab_farcall_entry_number(func_num) ;
   else if (parse_string(1,"MEM ",NULL) != 0)
      return grab_memory_entry_number(func_num) ;
   else if (parse_string(1,"PORT ",NULL) != 0)
      return grab_port_entry_number(func_num) ;
   else if (parse_string(1,"MSR ",NULL) != 0)
      return grab_msr_entry_number(func_num) ;
   else if (parse_string(1,"OPCODE ",NULL) != 0)
      return grab_opcode_name(func_num) ;
   else if (parse_string(1,"I2C ",NULL) != 0)
      return grab_i2c_entry_number(func_num) ;
   else
      return 0 ;
}

/*=============================================================*/
/* Put the interrupt and function number into the separator    */
/* line just above the intlist entry preceding the cursor pos  */
/*=============================================================*/

int number_one_int()
{
   char func_num[14] ;			/* 2->int, 4->AX, 6->extra reg, NUL */
   int oldpoint ;
   
   while (to_separator_line(-1))	/* find previous separator line */
      {
      oldpoint = point ;
      if (grab_entry_number(func_num))	/* does it belong to an intlist entry? */
	 {				/*   if yes, success, else try again */
	 point = oldpoint + 11 ;	/* skip NL and first ten dashes */
	 delete(point,point+13) ;	/* replace 13 dashes by the function */
	 stuff(func_num) ;		/*   number and extra register */
	 point = oldpoint + 9 ;		/* back to category letter position */
	 return 1 ;
	 }
      point = oldpoint ;
      }
   return 0 ;				/* if we get here, we failed */
}

/*=============================================================*/
/* Put the interrupt and function number into the separator    */
/* line just above one or more intlist entries preceding the   */
/* current cursor position, letting user know of progress      */
/*=============================================================*/

command number_int() on intlist_tab[FKEY(12)]
{
   int i, hit_top = 0 ;
   
   for (i = 0 ; i < iter ; i++)
      {
      if (!number_one_int())
	 {
	 hit_top = 1 ;
	 say("No prior entry.") ;
	 break ;
	 }
      if (((i+1) % NUMBER_INT_PROGRESS_INTERVAL) == 0)
	 say("%4d...",i+1) ;
      }
   if (iter > 1 && !hit_top)
      say("Done.") ;
   iter = 1 ;
}

/*=============================================================*/
/*=============================================================*/

int line_has_see_also()
{
   int len ;
   
   to_begin_line() ;

⌨️ 快捷键说明

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