din.c

来自「RISC处理器仿真分析程序。可以用于研究通用RISC处理器的指令和架构设计。在l」· C语言 代码 · 共 68 行

C
68
字号
/************************************************************************* Copyright (C) 1989, 1990, 1991, 1992, 1993                    	**                   Rabin A. Sugumar and Santosh G. Abraham		**									** This software is distributed absolutely without warranty. You are	** free to use and modify the software as you wish.  You are also free	** to distribute the software as long as it is not for commercial gain,	** you retain the above copyright notice, and you make clear what your	** modifications were.							**									** Send comments and bug reports to rabin@eecs.umich.edu			**									*************************************************************************//* Preprocessor to convert traces in DIN format to format accepted      * * by simulator.  (Not very efficient)                                  */#include <stdio.h>extern int trace_type;extern FILE *in;din (ret_buffer)unsigned **ret_buffer;{  int l, indx, type;   unsigned addr;   char s[256], *status;   static unsigned buffer [1000];   indx = 0;   *ret_buffer = buffer;   for (l=0; l<1000; l++) {     if (status = fgets (s, 256, in)) {       sscanf (s, "%d%x", &type, &addr);       switch (type) {       case 0:	 if (trace_type & 0x2) {	   buffer[indx] = addr;	   indx++;	 }	 break;       case 1:	 if (trace_type & 0x4) {	   buffer[indx] = addr;	   indx++;	 }	 break;       case 2:	 if (trace_type & 0x1) {	   buffer[indx] = addr;	   indx++;	 }	 break;       case 3:       case 4:	 break;       default:	 fprintf (stderr, "Unknown access type %d\n", type);       }     }     else {       break;     }   }   return (indx); }

⌨️ 快捷键说明

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