:i	static char dmp_ascd_sccs_id[] = "%W% %G%";
:1#include "V.h"
/*
* Produce a (more-or-less) readable ASCII dump of the string.  Note that we
* simply ignore the sign bit here; you have to use dmp_hexd() to distinguish
* signed from unsigned character..
*/
dmp_ascd(f,pa,pz,msg,adr)
	int   f;		/* Output file number */
	char *pa, *pz;	/* First and last bytes */
	char *msg;		/* Message for first line, if nonnull */
	Ulong adr;		/* Address to show, if no message */
{	char  c, d;
	int   col = 0;

	if (!hex_as) if (!(hex_as = (CP)MallocM(HXLINE+1,"hex_as"))) Fail;
	if (msg) {
		sprintf(hex_as,"%s         ",msg);
	} else {
		sprintf(hex_as,"%8ld:",adr);
	}
	while (pa <= pz) {
		c = *pa++;
		adr++;
		Switch(d = dsp(c)) {
		  case '_':
			Switch(d = B7(c)) {
			  case '\0':
				hex_as[INDENT+col++] = '\\';
				hex_as[INDENT+col++] = '0';
				break;
			  case '\n':
				hex_as[INDENT+col++] = '\\';
				hex_as[INDENT+col++] = 'n';
				break;
			  case '\r':
				hex_as[INDENT+col++] = '\\';
				hex_as[INDENT+col++] = 'r';
				break;
			  case '\t':
				hex_as[INDENT+col++] = '\\';
				hex_as[INDENT+col++] = 't';
				break;
			  case 0x7F:
				hex_as[INDENT+col++] = '\\';
				hex_as[INDENT+col++] = 'D';
				break;
			  default:
				if (d < ' ') {
					hex_as[INDENT+col++] = '^';
					hex_as[INDENT+col++] = (d & 0x0F) + 'A';
				} else
					hex_as[INDENT+col++] = (d & 0x7F);
			}
			break;
		  case 0x7F:
			hex_as[INDENT+col++] = '\\';
			hex_as[INDENT+col++] = 'D';
			break;
#ifdef NOTNEEDED	/* This is just confusing... */
		  case '\\':
			hex_as[INDENT+col++] = '\\';
			hex_as[INDENT+col++] = '\\';
			break;
#endif
		  default:
			hex_as[INDENT+col++] = d;
			break;
		}
		if (col >= PERLINE-1) {	/* Line full */
			hexout(f,col,0);
			sprintf(hex_as,"%8ld:",adr);
			col = 0;
		}
	}
	if (col > 0) {	/* Final fragment */
		hexout(f,col,0);
		col = 0;
	}
fail:
	return 0;
}
