#include <stdlib.h>
#include <stdio.h>

void dump_addr(unsigned char *buf)
{
	int i=0;
	while (!(*buf&1)) {
		if (i!=6) putchar(*buf>>1); else {putchar('-'); putchar('>');}
		i++;
		buf++;
	}
	putchar('\n');
}

void hdump(unsigned char *buf,int n)
{
	int fh=0,i,j,dir=0;

	do{
		j=n; if (j>16) j=16;
		printf("%8x ",dir);
		for (i=0;i<16;i++) {
			if (i<j) printf(" %02x",buf[i]); else printf("   ");
			if (i==7) putchar(' ');
		}
		printf("  ");
		for (i=0;i<j;i++) putchar(isprint(buf[i]&0x7f) ? buf[i]:'.');
		putchar('\n');
		dir+=j;
		buf+=j;
		n-=j;
	}while (n);
	fflush(stdout);
}
