Disk Examine

By Richard Dimond

Originally published in EUG #28

This is another useful program from Electron User that I have converted to m/code. I have also made some changes to enable you to move back a sector as well as forward. Also to re-run to enter a new address without having to break out of the program.

The opening screen is set as in my earlier utilities and then the routine 'input' is called for entering an address. As I had no idea how to do this, and could not make up one, I have used the routine from TRACKER, also present on this EUG disk.

After entering an address, the program goes to the mainloop lines 2460-680. This contains two nested loops, 'loop2' lines 290-600 and 'loop' lines 2450-560.

The mainloop first sets up OSWORD with A=&72 to read one sector at disk address 'dadd' to address &3000. The variable 'byte' is set to zero. This is the byte number to be printed at the left of the screen.

'loop2' then calls the routine 'title' to clear the screen and print the title. The disk address, track number and sector are then printed.

The routine 'daprt' uses the routine 'hexprt2' which is a modification of 'hexprt' I made to avoid printing the leading zeros.

I made up the routine 'decprt' as a simpler routine for printing decimal numbers as this program only used a single byte number to print up to 255. If the number is less than 10, the program jumps to 'one' to print a single digit. If it is greater than 199, 200 is deducted and a 2 printed, the remainder is then stored in 'temp'. Similarly for numbers between 100 & 199, 100 is deducted, the remainder stored and 1 printed. The remainder is then reloaded into A and then divided by 10 by subtracting 10 and counting the number using X register in loop 'lp'. This number is printed after being transferred to A register followed by the remainder in 'temp'.

The string 'head2' is then printed and count loaded with 16 to repeat 'loop' 16 times to print the lines of each half of the sector.

Lines 460,470 print the byte numbers, the comparisons set X to number of spaces needed to line up the numbers and the colon is printed after the number. Line 480 loops round eight times to print a space and the hex value of the bytes. Then line 490 prints two spaces. The loop 'llp2' prints characters if printable or a '.' if not.

The cue to press a key is printed (Lie 570) and the program waits.

The first time a key is pressed, since 'count2' is initially 2, 'loop' will be repeated to print the second half of the sector.

When the sector has been printed, the options are printed (Lines 610, 620). The AND&DF in line 640 allows the use of the lower case letters. When the program waits, carry is set if ESCAPE is pressed and this returns to BASIC.

Line 650 increases 'dadd' and, if this goes to zero, 'dadd+1' is increased. The value of 'dadd' is decreased at line 660 and 'dadd+1' is decreased when 'dadd' is decreased to 255.

If R is pressed, the program jumps to 'st' and 'start' to enter a new address. Otherwise the mainloop is repeated.

Richard Dimond, EUG #28