{* * @(#) hexdump.pas - Program for binary file hexadecimal dumping. * (c) 1994 Ivan Maidanski http://ivmai.chat.ru * Freeware program source. All rights reserved. ** * Language: Turbo Pascal * Tested with: Turbo Pascal v7.0 * Last modified: 1994-08-12 13:20:00 GMT+04:00 *} program HexDump; {$I-} var A: Word; var N: Byte; var F: File of Byte; procedure TestErr; begin if IOResult<>0 then Halt(2) end; procedure Init; begin if ParamCount=0 then begin WriteLn; WriteLn('Binary file Hexadecimal Dumping program'); WriteLn('Usage parameters: source_file > destination_file'); Halt(1) end; Assign(F,ParamStr(1)); Reset(F); TestErr; A:=0 end; procedure PrintHex(N: Byte); const Hex: array[0..15] of Char= ('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); begin Write(Hex[N shr 4],Hex[N and 15]) end; procedure PrintAddr; begin PrintHex(A shr 8); PrintHex(A and 255); Write(' ') end; procedure PrintToFile; begin if A and 15=0 then PrintAddr; Write(' '); if A and 15=8 then Write('- '); PrintHex(N); if A and 15=15 then WriteLn; Inc(A); TestErr end; procedure Run; begin while A0 then WriteLn; TestErr end; begin Init; Run end.