DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦99e628caa⟧ TextFile

    Length: 1920 (0x780)
    Types: TextFile
    Names: »HEXDUMP.PAS«

Derivation

└─⟦74e5ee6fb⟧ Bits:30002683 PolyPascal-86 v. 3.11 - Piccoline
└─⟦74e5ee6fb⟧ Bits:30003934 SW1402 PolyPascal v3.11 (dk) til Piccoline
    └─ ⟦this⟧ »HEXDUMP.PAS« 

TextFile

PROGRAM hexdump; æ$K-,R-å

æ This program will output a hex dump af any disk file. Each    å
æ line shows the address of the first byte of the line, then 16 å
æ bytes in hex, and then the same bytes in ASCII, if they are   å
æ printable. On running the program, you must specify the name  å
æ of the input and output files on the command line. The output å
æ file defaults to the console, i.e. the CON: device.           å

TYPE
  sector = ARRAYÆ0..7,0..15Å OF byte;
  hexstring = STRINGÆ4Å;

VAR
  address,l,p,n: integer;
  ch: char;
  buffer: sector;
  infile: FILE;
  outfile: text;

FUNCTION hex(number,digits: integer): hexstring;
CONST
  hexdigit: ARRAYÆ0..15Å OF char = '0123456789ABCDEF';
VAR
  d: integer;
  h: hexstring;
BEGIN
  hÆ0Å:=chr(digits);
  FOR d:=digits DOWNTO 1 DO
  BEGIN
    hÆdÅ:=hexdigitÆnumber AND 15Å;
    number:=number SHR 4;
  END;
  hex:=h;
END;

BEGIN
  IF (argcnt<1) OR (argcnt>2) THEN
  BEGIN
    writeln('Syntax: HEXDUMP <infile> Æ<outfile>Å'); halt;
  END;
  assign(infile,argstr(1)); æ$I-å reset(infile) æ$I+å;
  IF iores>0 THEN
  BEGIN
    writeln('HEXDUMP: "',argstr(1),'" does not exist'); halt;
  END;
  IF argcnt=2 THEN
  assign(outfile,argstr(2)) ELSE
  assign(outfile,'CON:');
  rewrite(outfile);
  address:=0;
  REPEAT
    blockread(infile,buffer,1,n);
    IF n<>0 THEN
    FOR l:=0 TO 7 DO
    BEGIN
      write(outfile,hex(address,4),' ');
      FOR p:=0 TO 15 DO
      BEGIN
        IF p=8 THEN write(outfile,' ');
        write(outfile,hex(bufferÆl,pÅ,2):3);
      END;
      write(outfile,'  ');
      FOR p:=0 TO 15 DO
      BEGIN
        ch:=chr(bufferÆl,pÅ);
        IF (ch>=@32) AND (ch<=@126) THEN
        write(outfile,ch) ELSE write(outfile,'.');
      END;
      writeln(outfile);
      address:=address+16;
    END;
  UNTIL n=0;
  close(infile); close(outfile);
END.
«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»«nul»