h49380
s 00111/00000/00000
d D 1.1 80/05/15 14:27:06 lcd 1 0
e
u
sunix
lcd
U
t
T
I 1
#

#include "globals.h"
#include <stdio.h>

/*
 *	look.c: look into dump image
 */

CONST	char	*_S_look	"%W%";

#define	BLOCKSIZE	512
#define	noblock		-1L

/*
 *	readdmp: read a dump block
 */

PROCEDURE readdmp( blkno, block )

CONST	long	blkno;
	char	block[ BLOCKSIZE*2 ];

BEGIN	fseek( o_dump, blkno*512L, 0 );		/* find block */

	fread( block, BLOCKSIZE, 2, o_dump );	/* read block */
END

/*
 *	rdBlock: block of memory
 */

PROCEDURE rdBlock( phys, len, blkadr )

CONST	long	phys;
	integer	len;
VAR	char	*blkadr;

BEGIN	fseek( o_dump, phys, 0 );

	fread( blkadr, len, 1, o_dump );
END




/*
 *	look block
 */

VAR	long	currblk		noblock;
	char	block[ BLOCKSIZE*2 ];

/*
 *	display: display a chunk of dump file
 */

PROCEDURE display( physl, physh )

CONST	long	physl;
	long	physh;

BEGIN	VAR	long	blk;
		integer	offset;
		long	phys;

	/*	printf("lh %lo %lo\n", physl, physh );		*/

	dsplysz = physh-physl;

	phys = physl;

	LOOP	blk = phys/512L;

		IF currblk != blk
		THEN	currblk = blk;
			readdmp( blk, block );
		END;

		offset = (integer)( phys MOD 512L );

		/*	printf("phys %lo  %d\n", phys, offset );	*/

		format( &block[ offset ], phys == physh );

		WHEN phys >= physh DO EXIT;

		phys = phys + step;
	END;
END

/*
 *	look: look at a chunk of physical memory
 */

PROCEDURE look()

BEGIN	VAR	long	physl;
		long	physh;
		char	word[ MAXLINELENGTH ];

	getadr( &physl );
	getnum( &physh );

	IF physh == -1L
	THEN	physh = physl;
	ELSE	addr = physh;
	END;

	display( physl, physh );
END
E 1
