Colorizing the big bright green state machine
I've been busily optimizing OSLEC for the blackfin, X86, and X86_64 architectures.
N0: 11000011111111000000000000000000
N1: 10000000000000000000000000000000
N2: 10000000000000000000100000000000
N3: 10000000000000000000100000000001
N4: 10000000000000000000100000000011
...
BEFORE: 11000011111111000000000000000000 AFTER : 10000000000000000000000000000000
BEFORE: 11000011111111000000000000000000 AFTER : 10000000000000000000000000000000
BEFORE: 11000011111111000000000000000000 AFTER : 10000000000000000000000000000000
BEFORE: 11000011111111000000000000000000 AFTER : 10000000000000000000000000001000
/* Diffbits - released into the public domain 2008 by Michael Taht */
#include
// Some ansi standard strings
#ifdef HTML
#define REDON ""
#define REDOFF " "
#else
#define REDON "\033[01;34m"
#define REDOFF "\033[00m"
#endif
static int diffbits_64(long a,long b,int size) {
int color = 0;
int abit = 0;
int bbit = 0;
int status = 0;
int i;
for(i = 0; i < size; i++) {
abit = (a&1);
bbit = (b&1);
if(abit != bbit) {
status = 1;
if(color !=1) {
printf(REDON);
color = 1;
}
} else {
if(color ==1) {
printf(REDOFF);
color = 0;
}
}
printf("%d",abit);
a = a >> 1;
b = b >> 1;
}
if(color ==1) {
printf(REDOFF);
color = 0;
}
return (status);
}
int diffbits64(int a, int b) {
return diffbits_64(a,b,sizeof(long long)*8);
}
int diffbits32(int a, int b) {
return diffbits_64(a,b,sizeof(int)*8);
}
int diffbits16(int a, int b) {
return diffbits_64(a,b,sizeof(short)*8);
}
int diffbits8(char a, char b) {
return diffbits_64(a,b,sizeof(char)*8);
}
diffbits(long a, long b) {
diffbits_64(a,b,sizeof(int)*8);
}
#ifdef TEST
int main () {
diffbits(1,0); printf("\n");
diffbits(-1,1); printf("\n");
diffbits(555,225); printf("\n");
diffbits(16323,-12225); printf("\n");
diffbits8(1,-1); printf("\n");
diffbits16(1,-1); printf("\n");
diffbits16(16323,-12225); printf("\n");
diffbits32(1,-1); printf("\n");
diffbits32(1,2); printf("\n");
diffbits32(16323,-12225); printf("\n");
diffbits64(1,-1); printf("\n");
diffbits64(1,2); printf("\n");
diffbits64(16323,-12225); printf("\n");
}
Labels: ardour, computers, statistics
Resume,Songs,
My new blog, NeX-6, My facebook page
Orgs I like
The EFF - keeping free speech in the world
Musical stuff I like
Jeff, Rick, Ardour, Jack
Prior Rants -
Transport strike over, working too hard
ioquake3 gets ipv6
No Luz, no taxi
Blood in the water
getting ready to hang it up
Lock up the *ssholes
Big batch of OLPCs distributed in Nepal
No right to not remain silent
Election insanity, and other unpopular causes
Back in Nicaragua, haunted by jellyfish
Best of the blog:
Uncle Bill's Helicopter - A speech I gave to ITT Tech - Chicken soup for engineers
Beating the Brand - A pathological exploration of how branding makes it hard to think straight
Inside the Internet Mind - trying to map the weather within the global supercomputer that consists of humans and google
Sex In Politics - If politicians spent more time pounding the flesh rather than pressing it, it would be a better world
Getting resources from space - An alternative to blowing money on mars using NEAs.
On the Columbia - Why I care about space
Authors I like:
Doc Searls
Where's Cherie?
UrbanAgora
Jerry Pournelle
The Cubic Dog
Evan Hunt
The Bay Area is talking
Brizzled
Zimnoiac Emanations
Eric Raymond
Unlocking The Air
Bob Mage
BroadBand & Me
SpaceCraft
Selenian Boondocks
My Pencil
Transterrestial Musings
Bear Waller Hollar
Callahans