%external %routine DUMP (%string(63) fname) %external %integer %function %spec EXIST (%string(31) file) %external %integer %function %spec SMADDR (%integer chan,%integername len) %external %routine %spec DEFINE (%string(63) def) %external %routine %spec CLEAR (%string(63) chan) %external %routine %spec CLOSESM (%integer chan no) %string(63) out %integer pos, ad, len, ch, bpos %const %byteinteger %array hexchar(0:15) = %c '0','1','2','3','4','5','6','7', '8','9','A','B','C','D','E','F' %routine PHEX (%integer n, p) %integer j %cycle j = p*4 - 4, -4, 0 print symbol (hexchar((n >> j) & x'f')) %repeat %end %if fname -> fname . ("/") . out %start define ("1," . out) select output (1) %finish %if exist(fname) = 0 %start printstring ("DUMP fails - file "); print string (fname) print string (" does not exist, or no access"); newline %return %finish define ("SM17,".fname) ad = smaddr (17,len) bpos = 0 print string ("Header: ") %cycle pos = ad-32, 4, ad phex (shortinteger(pos), 4); space %repeat newline %cycle pos = ad, 1, ad+len-1 %if bpos = 0 %then phex (pos-ad, 8) %and printstring(": ") ch = byteinteger(pos) %if ' ' <= ch <= 126 %start printsymbol(ch) spaces(2) %finish %else %start phex (ch, 2) space %finish bpos = bpos + 1 %if bpos = 16 %then newline %and bpos = 0 %repeat closesm(17) clear("17") %end %end %of %file