4.5. Patch/Dump

Version I.5, September 1978

page235 PATCH is a utility which was written as a personal piece of software, and has become part of the soul of the system. Even in the wonderful world of Pascal programming, it seems that the need to see disk blocks in the not so wonderful world of HEX remains. The usefulness of this proves itself over and over again. Usually this pertains to studying the output of a Pascal program which has created a file of some structured type, however the data in the output file just doesn't seem right. Patch comes to the rescue. Patch lets you see just exactly what bits are where, arid even lets you change them to be the way they should be.

On X(ecuting PATCH, the prompt line is

C(onsole, P(atchwrite, W(holewrite, Q(uit
The options available are:

In the C(onsole mode, the prompt line changes with each command. The prompt line always reflects the commands available at any given time, and no more. The full prompt line is:

Patch: R(ead, S(ave, H(ex, M(ixed, G(et, Q(uit [nn]
The number in square brackets at the end of the prompt is the current block being patched. The first command to use is G(et. G(et will prompt
Filename: <cr for unit i/o>

page236 Respond to this prompt with the name of the file to be patched. If the disk/device has no directory, or has some problem with the directory, reference it by its Pascal unit number. Type a carriage return to this prompt, and the prompt is:

Unitnum to patch [4,5,9..12] (0 will Quit) ?
Having typed a successful entry to one of the the above prompts, the prompt will now be extended by the R(ead command. R(ead will read up a block from the file/unit. The prompt on entering R(ead command is
BLOCK:
Respond with a block number in the file/unit specified. There is no range checking provided on this read, so exercise care in the number typed. The prompt line is now extended with H(ex, M(ixed and the block number in square brackets. H(ex and M(ixed display the block read. Using the H(ex command displays the block entirely in hexadecimal characters, using the M(ixed command will display printing ASCII characters were possible, and hexadecimal values elsewhere. The prompt line is:
Alter: H(ex, T(ext, S(tuff, Q(uit
The vector keys on the terminal causes the cursor to move around in the data, notice that there the cursor will remain only on the data, and will not move off the data. On terminals without vector keys, or poorly done setups, the character motion table is as follows:

Uup
Zdown
Lleft
Rright

Typing a hexadecimal character changes the character the cursor is over provided that only one or more of the data positions is changed, when Q(uitting from Alter mode, the Patch prompt line will be extended with the S(ave command. Typing S(ave writes the changed data back to from where it was read. In the Alter mode, there is one optional command: S(tuff. Typing the S(tuff command displays the prompt line:

Stuff for how many bytes:
Key a number from 0 to 512. Type carriage return to cause patch to accept the number, the prompt line changes to: page237
Fill with what hex pair:
Key a byte value in hexadecimal. The data reappears on the screen, with the number of bytes specified, from the position of the cursor filled with the data value specified, to the hex pair prompt.

Using the Patch write command causes a full screen prompt to appear:


This procedure writes out sequential blocks to any file as a patch dump. Type the prefix character of the option to be changed. Type 'F' to PRINT, 'Q' to QUIT.
A( Input File
B( Begin Block 11
C( Num. of Blocks

E( Output File

G( Hexadecimal
H( ASCII
I( Decimal
J( Octal
K( Decimal Bytes
L( Octal Bytes
M( Krunch
N( Double Space

Following each of the fields is the current value of that field. Typing the character in front of the field places the cursor after the field, and removes the current value. Typing ‘Y’ or ‘T’ sets a boolean value to True, any other character sets the field to False. The Input File and Output File fields require a filename to be typed followed by carriage return. The integer fields (Begin Block, and Number of Blocks) require a number to be typed followed by carriage return or space. Any other character sets the value of the field to some unspecified value.

The other options at the Patch write level are Print and Quit. Both cause Patch to return to the outer level. Quit does it straight away, Print dumps out the file in the requested format on the way. The options available for the dump need to be selected, the default is none. The options Krunch and Double Space affect the formatting of the output. Krunch, when true, removes blank lines between logical output lines. Double Space when true, double spaces all output.

page238 Using the W(holewrite command causes the full page prompt:


This procedure writes any number of blocks from an existing file to a new file, unchanged. Simply specify the necessary parameters Type 'P' to PUT, 'Q' to QUIT
I(nput File
S(tart Block
N(umber of Blocks

O(utput File

The protocol for changing the fields at this level is the same as that for the Patch write level. The Whole write level is that which allows one to mix, match and mingle files. Put and Quit both cause Patch to return to the outer level. Put writes to the file on its way, Quit does not.

Notice that the Patch write and Whole write levels remember their vital parameters across sessions (while remaining in Patch). The Console level will clear all memory of the session. The Patch write level paginates its output, after each block written, a form-feed is generated (specifically PAGE(OUTPUTFILE)).


This page last regenerated Sun Jul 25 01:09:11 2010.