EDBIN

1.1 Introduction

EDBIN allows you to EDit BINary files i.e. executable object code files or data files that cannot be loaded into an ordinary word processor or text editor. The file can be examined after loading into memory and modified if necessary. Commands are available to edit the file using hexadecimal or ascii values, initialise blocks of the file to a specified constant, copy blocks to different locations, search for a specific string and compare two blocks of the file. After editing, the data can be written back to the original file or to a different file if required. All EDBIN commands can be terminated at any time using CNTRL-C or suspended using CNTRL-S. If the output is suspended using CNTRL-S it can be restarted using any key except CNTRL-C CNTRL-S or BREAK. The EdBin program can be found on the DOS Plus Boot Disc, disc 1.

1.2 Starting EdBin

To start EDBIN type

EDBIN <filename>

where <filename> is the file that you want to edit. The file will be loaded into memory by EDBIN when it starts up and it will then respond with a '-' prompt to indicate that it is ready to accept commands.

Alternatively EDBIN can be started up by simply typing

EDBIN

EDBIN will be loaded and respond with the '-' prompt as before but no file will be loaded to edit. In this mode memory can be examined and modified and written to a disc file. If at any time the user wants to edit a file rather than memory the file can be loaded in using the R(EAD) <filename> command which loads the file in as if EDBIN <filename> had been typed.

1.3 EdBin Commands

All the EDBIN commands are single letter commands followed by up to three parameters. The following table summarises the available commands.

Command Function  
                                                       
C <range> <address> C(ompare) blocks of memory
D (<range>) D(ump) memory in hex and asci formats
E <address> E(dit) memory using hex or ascii values
F <range> <byte I word> F(ill) memory with a constant value
H H(elp) give summary of commands
M <range> <address> M(ove) blocks of memory
Q Q(uit) return to DOS + command prompt
R <filename> R(ead) file into memory for editing
S <range> <"string"> S(earch) memory for specified string
W (<filename>) W(rite) memory to disc file

where

<address>   = (<segment>:) <offset>
<range>     = (<segment>:) <start offset> <end offset>

The above commands are now explained in more detail. Where <offset> is used it refers to a hexadecimal offset address which can be entered as 1 to 4 digits – leading zeros can be omitted ie. 7A can be entered as 7A, 07A or 007A. If more than 4 hex digits are entered the most significant digits will be truncated ie. 12345 will be treated as 2345. Where an <end offset> is required it refers to the end offset + 1 i.e.

D 100 180

will dump the bytes between 100H and 17FH inclusive. To specify the end address of a 64 K segment in 16 bits an end offset of 0 must be used i.e.

F C000 0 E5

will fill the last 4 Kbytes of the current segment with the byte E5H

Where <segment> is used it refers to a 80186 segment address which can also be entered as 1 to 4 hex digits but must be followed immediately by a : to indicate that it is a segment value. In all relevant commands below if no segment address is specified the most recently specified value is used or the segment address of the file buffer if no previous value has been specified. For all commands any leading or trailing spaces will be ignored. Items enclosed in <> brackets indicate parameters that the command must have, items also enclosed in () brackets indicate optional parameters that do not have to be specified. Items separated by the character indicate that the command can take several different parameters but only one can be specified at a time.

All commands can be entered in upper or lower case (or both).

Contents | Move

C(ompare)

Syntax

C (<segment>:) <Source start> <source end> (<segment>:) <dest start>

where

<start> = <start offset> ; <end> = <end offset>
<dest> = <destination>

Function

Compare the specified block of memory with another block of the same size given by the destination start address.

Description

If there are any differences found between the two specified blocks they are reported as follows -

<source address> <source byte>  <dest address> <dest byte>

The address is displayed in standard segment:offset form and the byte at that address is displayed in both hexadecimal and ascii forms.

If there are no differences between the two blocks EDBIN will not display anything and simply return with the '-' prompt to indicate that the blocks are identical.

The Compare command can be used on blocks up to 64 Kbytes in length by specifying an end offset of 0 for the source end address. If a compare of greater than 64 Kbytes is required it can be done in blocks of 64 Kbytes.

Example

C 300 500 1000

will compare 200H bytes at 300H to 4FFH in the current segment with 200H bytes at 1000H to 11FFH in the same segment.

C 0 0 2000:0

compares the whole 64 Kbytes of the current segment with another 64 K block at 2000:0

Contents | Move

D(ump)

Syntax

D (<segment>:) (<start offset>) (<end offset>)

Function

Display the specified area of memory

Description

The memory contents are displayed as hexadecimal values and ascii characters. Each line of the memory dump displays the memory address in segment:offset form followed by 16 bytes of hexadecimal values and 16 bytes of ascii characters. Characters outside the ascii range 20H - 7EH are shown as a full stop. All the parameters in the above commands are optional. If the segment address is omitted the last value will be used, if the start and end offsets are omitted the last end address is used as the start address and the last end address + 080H is used as the end address, if the end address is omitted the start address + 080H is used.

Note – the above applies only if no other intervening commands have been used which change the current segment address or current offset address.

The minimum number of bytes that can be displayed is 16 bytes i.e.

D 100 105

will display 100H to 10FH

Example

D 1000 1580

will display memory from 1000H to 157FH inclusive in the current segment in the format described above. If the dump command is subsequently used with no parameters i.e.

D

128 bytes of memory from 1580H to 15FFH will be displayed. Further D commands entered with no parameters will display the next 128 bytes of memory.

Contents | Move

E(dit)

Syntax

E (<segment>:) <start offset>

Function

Allows memory contents to be examined and new values to be entered if required.

Description

A line of 16 bytes of memory is displayed in hex and ascii formats initially with the cursor under the least significant digit of the first byte specified. Cursor movement and data entry is controlled using the following keys

LEFT             move cursor left, if at far left display previous 16 bytes
RIGHT move cursor right , if at far right display next 16 bytes
UP display next 16 bytes
DOWN display previous 16 bytes
   
SHIFT-LEFT move cursor to far left of current field
SHIFT-RIGHT move cursor to far right of current field
   
COPY-DELETE toggle between hex field and ascii field

The display consists of two 16 byte fields – a hexadecimal display and an ascii display. The COPY-DELETE keys are used to switch between the two fields. (NOTE – on the Master 512 COPY is used as the ALTernate shift key of an IBM keyboard hence it should be used like a SHIFT key i.e. to toggle between the data entry fields copy should be pressed down first and held while DELETE is pressed). While the cursor is in the hex field data is entered in hex digits, each digit being shifted in from the right. To advance to the next field the normal cursor keys are used. SHIFTed cursor keys are used to move to the far left or right of the current field. If the cursor is in the ascii field data is entered as ascii bytes. The cursor is automatically advanced to the next field to allow text to be typed in directly. When text is entered at the far right of the field the next 16 bytes are automatically displayed to allow typing to continue over 16 byte boundaries.

NOTE – if data is being entered in the ascii field, control codes in the range 0 to 31 can be entered by pressing the appropriate key in conjunction with the CNTRL key. i.e. CNTRL-Z will enter the end of text marker 1AH. The only exception is CNTRL-C (value 03H) which is used to terminate the command. If the user wishes to enter this code it must be entered in the hexadecimal data field as hex digits 03.

The E(dit) command is terminated by pressing CNTRL-C

Example

E 3000:560

will display

3000:560 41 20 62 6F 74 20 6F 66 20 74 65 78 74 1A 07 00 A bot of text...

The spelling mistake in the text can be corrected by two methods

1 Move the cursor to the fourth byte in the hex field and enter the hex digits 6 and 9.

2 Use COPY-DELETE to move to the ascii field of the display and move to the fourth byte in this field and enter the character i.

CNTRL-C is then entered to terminate the command for both methods The editing can be checked by for example entering the command

D 560 570

which should display

3000:560 41 20 62 69 74 20 6F 66 20 74 65 78 74 1A 07 00 A bit of text...

Contents | Move

F(ill)

Syntax

F (<segment>:) <start offset> <end offset> <fill byte | word>

Function

Fills memory with a constant value between the specified addresses.

Description

The constant used can be specified as a byte or word value. If a word value is specified the least significant byte is written first.

An end offset of 0 can be used to specify a fill operation to the last byte in the specified segment.

Example

F 1000 1010 55

will fill bytes 1000H -100FH inclusive with the value 55H

F 1000 1010 1234

will fill bytes 1000H - 100FH inclusive with the word 1234H with the least significant byte written first.

Contents | Move

H(elp)

Syntax

H

Function

Give help information.

Description

The H command displays the EDBIN version number and a list of available commands with their required syntax. It does not take any parameters.

Example

H

Contents | Move

M(ove)

Syntax

M (<segment>:) <source start> <source end> (<segment>:) <dest start>

where

<start> = <start offset> ; <end> = <end offset>
<dest> = <destination>

Function

Move a block of memory to specified address.

Description

The specified block of memory is moved to the destination address. The block of memory at the source address is not generally affected by the move – it is simply copied to the given address. If an overlapping move is specified (i.e. a move where part of the destination block overlaps the source block) the data that could be overwritten by the operation is always moved first to ensure that the destination data is correct. The user should be aware that in these cases the source block must inevitably be corrupted in the overlapping area.

Example

M 100 740 1200:10

moves 640H bytes from 100H to 73FH to address 10H in segment 1200H

Contents | Move

Q(uit)

Syntax

Q

Function

Exit EDBIN and return to the DOS PLUS command line prompt.

Description

The Q command is used with no parameters. It closes the currently active file (if one exists), restores the DOS PLUS system environment and returns to the DOS PLUS command line prompt.

Example

Q

Contents | Move

R(ead)

Syntax

R <filename>

Function

Read a file into memory

Description

The specified file is read into memory at the start of the file buffer. The size of the file and the number of bytes actually read are displayed as the file is being loaded into memory. These two numbers should normally be the same but in the event of a disc error the number of bytes read will indicate how much of the file can be recovered.

When a file is loaded using the Read command the specified <filename> becomes the currently active file (CAF). This will remain active until a subsequent Read operation which will dose the previous CAF and the newly loaded file becomes the new CAF.

NOTE – if EDBIN is executed with a filename on the command line i.e.

EDBIN TEST.DAT

then TEST.DAT will automatically be loaded into memory as if a R TEST.DAT command had been entered. The file TEST.DAT therefore becomes the currently active file. (For more information on the use of the currently active file see the Write command)

Example

R FILE.EXE

loads the file FILE.EXE into memory at the start of the file buffer and resets the current command segment/offset variables so that file editing commands will operate on the file buffer.

NOTE – EDBIN will always load the file into memory at the start of its file buffer regardless of the type of file i.e. CMD or EXE files will not have the file header stripped off – the file will be loaded into memory in the same form as it appears on disc. The user should therefore be aware that in the above two cases the start of the code segment will be offset by the length of the header.

Contents | Move

S(earch)

Syntax

S (<segment>:) <start offset> <end offset> <"string">

Function

Search memory for specified text string.

Description

If any matching text strings are found it is reported as the start address of the string in segment:offset form. The address given is of the first byte of the matching string. The search string must be enclosed in double quotes (") and can be up to 72 characters in length. (Maximum length for complete command line is 80 characters). The end offset specified is the end address + 1 of the search area so to allow the search to continue right up to the end of a segment an end address of 0 can be specified i.e.

S 4000 0 "eric"

will search from 04000H up to 0FFFFH inclusive. The condition for a string to be found is that it must be completely contained within the search area, i.e. if string "eric" lives at 03FFDH then

S 0 4000 "eric"

will not report it but if our string "eric" lives at 03FFCH then the above search will find it. Any 8 bit character string can be searched for using escape sequences to allow control codes and characters above 07FH to be specified. (N.B. these are compatible with the MOS escape sequences). The | character is used to denote an escape sequence.

The following table shows how all the characters are specified.

         String                   hex byte                                                                                                                                      
  "|@" 0  
       
  "|a" or "|A" 1  
  to to  
  "|z" or "|Z" 1A  
       
  "|[" 1B  
  to to  
  "|_" 1F  
       
  " " 20  
  to to  
  "~" 7E  
       
except for following two special cases
       
  """" 22  
  "||" 7C  
       
Delete is entered as follows
       
  "|?" 7F  
       
Characters above 128 can be entered using the |! operator i.e.
       
  "|!<char>" 80 - FF  
       
where <char> is any of above 7 bit chars

Note – the characters in the search string are case dependent i.e. "ABC" will match "ABC" only not "abc" or "AbC" etc.

Any escape arguments not recognised are reduced to the argument alone i.e.

"|1" is reduced to "1 " etc

and any surplus redundant "I!" operators are ignored

i.e "|!|!|@" is reduced to "|!|@"

Any string not terminated by a " character or containing an odd number of " characters will be reported as bad strings i.e.

         String           Error                                                                                                  
       
  "abc No terminating "  
  "ab"" Single quote character in string  
  "ab"""c" As above  
       
A Bad String error will also be generated if no argument is supplied for the escape character | or if a null string or equivalent is specified i.e.
       
  String Error  
       
  "a|" No escape argument  
  "" Null string  
  "|!" Reduced to null string hence as above  

The search operation can be terminated at any time by pressing CNTRL-C

Example

S 100 7B00 "a text string"

will search from 100H to 7AFFH for the string "a text string". Any occurrences of the string in the specified might be reported as

01F3:0151
01F3:0279
01F3:7A01

Contents | Move

W(rite)

Syntax

W (<filename>)

Function

Writes the specified file or currently active file to a disc file.

Description

If the W command is used with no <filename> the modified data in memory is written back to the currently active file that was specified in the last R command. If a <filename> is specified the data is written instead to this specified file. Note that using the W command with a filename does not affect the currently active filename – therefore subsequent W commands with no filename will write the data to the filename specified in the last R command.

When writing out the file the number of bytes written is displayed on the screen – if EDBIN cannot write out all the bytes to disc an error message will be given to indicate that the disc is probably full.

Example

W

writes data from the file buffer to the currently active filename. The number of bytes written is equal to the length of the file loaded in by the R command.

Contents | Move

1.4 Error Messages

The following table lists the errors that may occur while using EDBIN.

Error Message         Cause
     
File not found   The R command has been used to try and read in a file that does not exist on the disc or the full path name for the file has not been specified.
     
Path not found   The R <filename> or W <filename> command has been used to read or write a file in a directory that does not exist.
     
Too many open files   The R command or W <filename> command has been used to try to open a file when there are already 20 open files. This error should not normally occur and it will only happen if some previous application has not closed its files on exit. EDBIN requires only 2 files open at any time.
     
Access denied   The R command has been used on a Read Only file. The R command attempts to open a file for R/W access assuming that the user may want to write the modified data back to the same file. To prevent this error the file should be set to R/W using FSET before entering EDBIN. This error may also occur if W <filename> has been used to write to a file that has the same name as an existing file that is marked R/O or if the specified directory is full.
     
Illegal file handle   The W command has been used when there is no Currently Active File to write the data to. The CAF must be activated by a R command or by specifying a filename in the command line when EDBIN is started up.

Contents | Move

About the Master 512 | Bibliography