Classic Computer Magazine Archive COMPUTE! ISSUE 17 / OCTOBER 1981 / PAGE 110

Atari Disk File Dump

Robert W. Baker
Atco, NJ

Here's another handy utility program for the Atari 800, for anyone with an 810 or 815 disk drive. It provides a hexadecimal dump of any disk file along with an ASCII representation of any valid ASCII characters. With this program you can quickly examine how Atari BASIC stores programs and data on diskette. This could be extremely valuable when debugging programs that write or read disk data files.

The program was written to provide only printed output, since most dumps would be too large for the display. Also, the printed output was formatted for the 80-column Atari 825 printer. If you only have the 40-column Atari 820 printer, the program can be easily modified for the shorter line length. Simply shorten the heading lines in program lines 302 and 310, stopping at "7." Then change the loop count in line 600 from 16 to 8 to print eight bytes per line instead of 16. You might also want to shorten the filename printout and remove the CHR$(15) and CHR$(14) from line 300. That should be all you have to change for the 40-column format.

To use the program, enter the filename for the disk file to be dumped, such as: FILEDMP.BAS The drive number always defaults to 1. The filename will be printed at the top of the listing along with a byte count heading. The dump will then follow with 16 bytes per line. At the end of each line is the ASCII representation of any data that is a valid ASCII character. All unprintable characters are printed as periods in the ASCII field.

As the dump is being printed you can press any key on the keyboard to halt the output. Then press "C" to continue the dump, "R" to restart and select another file to be dumped, or "S" to stop the program and terminate the dump.

If the end of the disk file is reached, the program will indicate on the dump the end of file (EOF) was reached. You may want to note the TRAP statement in program line 228. When an error is detected, the program branches to line 900. A PEEK of location 195 checks for error number 136. If an end of file (error #136) was detected, the program returns to ask for another filename. Otherwise, the detected error is indicated on the display and the program terminates after closing all files.

10 REM ********************************
25 REM HEX DISK FILE DUMP
35 REM BY : ROBERT W. BAKER
40 REM 15 WINDSOR DR, ATCO NJ 08004
60 REM ********************************
70 GRAPHICS 0
100 DIM H$(16), S$(16), F$(16)
110 H$ = "0123456789ABCDEF"
130 F$ = "D1:"
150 OPEN #1, 4, 0, "K"
200 PRINT CHR$(125) ; "   H E X F I L E D U M P " : ? : ?
210 PRINT "ENTER DISK FILE NAME"
220 INPUT S$ : F$ (4, 14) = S$
225 INPUT S$ = "" THEN 800
228 TRAP 900
230 OPEN #5, 4, 0, F$
280 OPEN #2, 8, 0, "P"
290 PRINT CHR$(125) ; "DEPRESS ANY KEY TO HALT PRINTER" : PRINT #2
300 PRINT #2, CHR$(15) ; "HEX DUMP OF FILE →" ; F$ ; CHR$ (14) : PRINT #2
302 PRINT #2 ; "BYTE# 0 1 2 3 4 5 6 7 8 9 A B C D E F"
310 PRINT #2 ; "----------------------------------------------------"
320 POKE 764, 255
370 U = INT(A/256) : GOSUB 1000
375 V = A - (V * 256) : GOSUB 1000
380 PRINT #2; ":" ;
400 S$ = ""
600 FOR X = 1 TO 16 : GET #5, V
610 GOSUB 1000 : PRINT #2 ; "" ;
615 S$(X) = "." : IF (V)31) AND (V < 123) THEN
620 A = A+1 : NEXT X : PRINT #2 ; "	" ; S$
640 IF PEEK <764> = 255 THEN 370
650 GET #1, X
700 POKE 752, 1 : PRINT
705 PRINT "CONTINUE, RESTART, OR STOP (C, R, S) ?" ;
710 GET #1, X : IF X = 67 THEN 290
730 IF X = 82 THEN 990
740 IF X <> 83 THEN 710
800 POKE 752, 0 : CLOSE #1 : CLOSE #2 : CLOSE #5 : END
900 V = PEEK(195) : IF V <> 136 THEN PRINT "ERROR#" ; V : GOTO 800
910 FOR A = X TO 16 : PRINT #2 ; "	" ; : NEXT A
920 PRINT #2 ; "	" ; S$ : PRINT #2 : PRINT #2 ; "EOF"
990 CLOSE #2 : CLOSE #5 : GOTO 200
1000 H = INT(V/16) : L = V - (H * 16)
1010 PRINT #2 ; H$(H + 1, H + 1) ; H$(L + 1, L + 1);
1020 RETURN