source: trunk/Softwares/MiBench/src/c/bitcount-bitstrng.c @ 135

Last change on this file since 135 was 117, checked in by rosiere, 15 years ago

1) Platforms : add new organization for test
2) Load_Store_Unit : add array to count nb_check in store_queue
3) Issue_queue and Core_Glue : rewrite the issue network
4) Special_Register_Unit : add reset value to register CID
5) Softwares : add multicontext test
6) Softwares : add SPECINT
7) Softwares : add MiBench?
7) Read_queue : inhib access for r0
8) Change Core_Glue (network) - dont yet support priority and load balancing scheme

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1/* +++Date last modified: 05-Jul-1997 */
2
3/*
4** bitstring(): print bit pattern of bytes formatted to string.
5**
6** By J. Blauth, Sept. 1992. Hereby placed into the public domain.
7**
8** byze:    value to transform to bitstring.
9** biz:     count of bits to be shown (counted from lowest bit, can be any
10**          even or odd number).
11** strwid:  total width the string shall have. Since between every 4 bits a
12**          blank (0x20) is inserted (not added after lowest bit), width of
13**          bitformat only is (biz+(biz/4-1)). Bits are printed right aligned,
14**          positions from highest bit to start of string filled with blanks.
15**          If value of strwid smaller than space needed to print all bits,
16**          strwid is ignored (e.g.:
17**                bitstr(s,b,16,5) results in 19 chars +'\0').
18**
19**   EXAMPLE:
20**   for (j = 1; j <= 16; j++) { bitstring(s, j, j, 16); puts(s); }
21**       1:                1
22**       2:               10
23**       3:              011
24**       d: 0 0000 0000 1101
25**       e: 00 0000 0000 1110
26**       f: 000 0000 0000 1111
27*/
28
29#include "bitcount-bitops.h"
30
31void bitstring(char *str, long byze, int biz, int strwid)
32{
33      int i, j;
34
35      j = strwid - (biz + (biz >> 2)- (biz % 4 ? 0 : 1));
36      for (i = 0; i < j; i++)
37            *str++ = ' ';
38      while (--biz >= 0)
39      {
40            *str++ = ((byze >> biz) & 1) + '0';
41            if (!(biz % 4) && biz)
42                  *str++ = ' ';
43      }
44      *str = '\0';
45}
46
47#ifdef TEST
48
49#include <stdlib.h>
50
51int main(void)
52{
53      char s[80]; long j;
54      for (j = 1L; j <= 16L; j++)
55      {
56            bitstring(s, (long)j, (int)j, 16);
57            printf("%2ld: %s\n", j, s);
58      }
59      return EXIT_SUCCESS;
60}
61
62#endif /* TEST */
Note: See TracBrowser for help on using the repository browser.