/*
	@(#)misc.c	1.5	(8/7/84 12:45:47)
*/
#include "standalone.h"

sleep(seconds)
	register int  seconds;
	{
	register int  scount;
	register int  lcount;

	for (scount = 0;  scount < seconds;  scount++)
	    {
	    for (lcount = 0;  lcount < 240000;  lcount++)
		{
		}
	    }
	}

strlen(strptr)
	register char  *strptr;
	{
	register int    length;

	length = 0;
	while (*strptr++ != '\0')
	    {
	    length++;
	    }
	return(length);
	}

strcmp(a,b)
	register char  *a;
	register char  *b;
	{
	register char   c;

	while ((c = *a++)  ==  *b++)
	    {
	    if (c == '\0')
		{
		return(1);
		}
	    }
	return(0);
	}

strcpy(from, to)
char *from, *to;
{
    bcopy(from, to, strlen(from)+1);
}

/*
bytecopy(from,to,length)
	register char  *from;
	register char  *to;
	register int    length;
	{
	while(length--)
	    {
	    *to++ = *from++;
	    }
	}
*/

bytefill(address,fillbyte,length)
	register char  *address;
	register char   fillbyte;
	register int    length;
	{
	while(length--)
	    {
	    *address++ = fillbyte;
	    }
	}

hexdump(address,length)
	register char  *address;
	register int    length;
	{
	register int    loop;
	register int    i,j;
	register char   c;

	loop = (length + 15) >> 4;
	putchar('\n');
	for (i = 0;  i < loop;  i++)
	    {
	    printf("%6x:  ",address + (i << 4));
	    for (j = 0;  j < 16;  j++)
		{
		c = *(address + (i << 4) +j);
		printf("%2x ",c&0xff);
		}
	    printf("  ");
	    for (j = 0;  j < 16;  j++)
		{
		c = *(address + (i << 4) +j);
		c &= 0xff;
		if ('\040' < c  &&  c < '\177')
		    putchar(c);
		else
		    putchar ('.');
		}
	    putchar('\n');
	    }
	}

error(number,format,p1,p2,p3,p4,p5,p6,p7,p8)
	int	number;
	{
	char	buffer[128];

	printf ("\nboot: Error %d has occurred.\n", number);
	printf("boot: ");
	printf(format,p1,p2,p3,p4,p5,p6,p7,p8);
	printf("\nHit RETURN to restart boot program: ");
	getlin(buffer,"",-1);
	( (int (*)()) 0x400000) ();
	}
