File: binary.c

package info (click to toggle)
x86info 1.18-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 468 kB
  • ctags: 442
  • sloc: ansic: 3,978; makefile: 115; asm: 67; sh: 38
file content (30 lines) | stat: -rw-r--r-- 515 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>

void binary (unsigned int n, unsigned long value)
{
	unsigned int i;

	for(i=0; i<n; i++, value<<=1)
		(void)putchar( (1<<(n-1) & value) ? '1' : '0' );
	(void)putchar('\n');
}

void binary32 (unsigned long value)
{
	int i;

	for(i=0;i<32;i++,value<<=1) {
		(void)putchar( (1<<31 & value) ? '1' : '0' );

		if(i==23 || i==15 || i==7)
			(void)putchar(' ');
	}
	(void)putchar('\n');
}

void binary64(unsigned long long value)
{
	binary32 (value>>32);
	printf ("           ");
	binary32 (value);
}