(* DUMP.PAS -- output memory dumps ** Copyright (c) 1995,1996 Jochen Metzinger ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2, or (at your option) ** any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *) UNIT dump; INTERFACE USES global; PROCEDURE DumpVar(VAR mem; count, offset: WORD); (* dump memory of a variable *) PROCEDURE DumpPtr(mem_ptr: POINTER; count, offset: WORD); (* dump memory at a pointer *) IMPLEMENTATION PROCEDURE DumpVar(VAR mem; count, offset: WORD); VAR bytes: ARRAY [0..$FFFE] OF BYTE ABSOLUTE mem; loc: WORD; hex_line, chr_line: STRING; BEGIN hex_line := ''; chr_line := ''; FOR loc := 0 TO count-1 DO BEGIN hex_line := hex_line + HexStr(bytes[loc],2) + ' '; IF (loc AND $0F) = $07 THEN hex_line := hex_line + '. '; IF bytes[loc] IN [$20..$7E,$80..$FE] THEN chr_line := chr_line + CHAR(bytes[loc]) ELSE chr_line := chr_line + '.'; IF (loc AND $0F) = $0F THEN BEGIN WriteLn(HexStr(offset, 4),' - ',hex_line,' ',chr_line); hex_line := ''; chr_line := ''; Inc(offset, $10); END; END; (* for *) IF count AND $0F <> 0 THEN WriteLn(HexStr(offset, 4),' - ',hex_line,'':50-Length(hex_line), ' ',chr_line); END; (* DumpVar *) PROCEDURE DumpPtr(mem_ptr: POINTER; count, offset: WORD); BEGIN DumpVar(mem_ptr^,count,offset); END; (* DumpVar *) END. (* dump *)