function hexdmp(F)
%HEXDMP Dump file contents in hexadecimal format similar to DOS 'DEBUG' utility
%	HEXDMP(bytes) reads the values in vector 'bytes' and displays each byte
%	of the file as a hexadecimal character. The ASCII interpretation of the
%	byte is printed as well (nonprinting characters show up as periods).
%
%	This routine emulates the DOS 'DEBUG' utilitiy.
%
%  See also GETBYTES
 
%  Created 1998 Feb 19
%  Ed.Doering@Rose-Hulman.Edu
%  Department of Electrical and Computer Engineering
%  Rose-Hulman Institute of Technology
%  Terre Haute, IN 47803-3999
%
%  Copyright (c) 1998 by Ed Doering.
 
 
% Size of the array
numbytes=length(F);

% Convert file to ASCII characters; convert nonprinting characters to '.'
s=F;
s(find(s<32 | s>126))=46;
s=char(s);

% Number of full rows in the output display, and size of last partial row
numfrows=floor(numbytes/16)
sizelast=mod(numbytes,16)

% Display the full rows
for i=1:16:numfrows*16,
   disp([sprintf('%8d: ',i)...
         sprintf('%02X ',F(i:i+7))...
         '- '...
         sprintf('%02X ',F(i+8:i+15))...
         '   '...
         s(i:i+15)...
         sprintf('\n')])
end

% Display the last (possibly partial) row
% (the following if-else allows arrays shorter than 16 values to print OK)
if numfrows==0
   i=1;
else
   i=i+16;
end

if sizelast<=8,
   disp([sprintf('%8d: ',i)...
         sprintf('%02X ',F(i:i+sizelast-1))...
         char(32*ones(1,3*(16-sizelast+1)))...
         s(i:i+sizelast-1)...
         sprintf('\n')])
else
   disp([sprintf('%8d: ',i)...
         sprintf('%02X ',F(i:i+7))...
         '- '...
         sprintf('%02X ',F(i+8:i+sizelast-1))...
         char(32*ones(1,3*(16-sizelast+1)))...
         s(i:i+sizelast-1)...
         sprintf('\n')])
end   

return