BMP - Binary Maintenance Program *** Introduction *** BMP is a program which facilitates the maintenance and manipulation of the contents of disks, disk files, and memory. Included are commands for symbolic entry and display of machine instructions (disassemble and assemble), ASCII and hexadecimal entry and display, as well as binary and decimal entry. User operation of the program is the same regardless of the type of object being accessed, although some commands are meaningless when accessing in a non-diskdump mode. *** Access Modes *** BMP has three addressing modes: memory, diskdump, and binary file. The memory mode allows the user immediate access to the computer memory and in many ways is similar in operation and effect to the interpretive debugger, IDB. Naturally, if the user is not careful while in this mode, he may easily destroy the resident copy of SDOS. The diskdump mode allows the user to examine the contents of a disk or diskfile in its 'raw' form. Locations specified by the user are the actual byte positions used in the file, as offset by a sector or cluster base given by the user (see the section on access commands). The binary file mode allows the user to access the program contained in a binary file as if it were loaded into memory. This means that the user can talk about the program without regard to how it is stored on disk -- in fact, BMP will take care of all the details involved in expanding the file if the user adds new data! BMP - Binary Maintenance Program *** Display Commands *** BMP will display data from a location in an output format selected by the user (the default display mode is ;H). ;A ASCII: the contents of the location is printed out as an ASCII character enclosed by apostrophes. Should the character not be a printing character, its hexadecimal value is printed. ;O OPCODE: the contents of the location are treated as though it were an instruction and its symbolic form is printed. Relative branches are printed with their absolute destinations rather than their relative displacements. Undefined op-codes have their hexadecimal value printed out preceeded by 'FCB'. ;H HEXADECIMAL: 1 byte is printed out in hexadecimal representation. ;X HEXADECIMAL: 2 bytes are printed out in hexadecimal notation. *** Commands *** The following is a list of commands, with descriptions and references to section names associated with each command. The following notation is used regarding objects in meta-brackets ('<>'): Lower case letters in meta-brackets describe special keys. For example, refers to the return key, is a line feed, and is an escape. Upper case letters in meta-brackets refer to strings with a specific syntactic meaning. For example, is an expression. A full list is given below. 2 BMP - Binary Maintenance Program Command Description Reference ======= =========== ========= + - * # % ! operators expressions ;E exit BMP Examine and Deposit / examine contents of location simple commands close current location simple commands examine next location simple commands ^ examine previous location simple commands ,/ display multiple locations simple commands deposit data simple commands deposit and examine next location simple commands ^ deposit and examine previous location simple commands = display value of expression simple commands Set Access Mode ;B binary, open access commands ;D diskdump, open access commands ;M memory access commands Display File Information ;H find header cluster of info commands ;L show load record layout of info commands Set Display Mode ;A ASCII display commands ;H single byte hex display commands ;X double byte hex display commands ;O opcode display commands Set Diskdump Mode Offset ;C set I/O base to cluster access commands ;S set I/O base to sector access commands Searching ? display search target and mask searching ?T set search target searching ?M set search mask searching ,?S perform search searching 3 BMP - Binary Maintenance Program *** Expressions: *** BMP allows simple expressions with strict left to right evaluation and no parenthesis. The recursive definition is as follows: An expression is: + addition - subtraction * multiplication & logical not ! logical or # logical exclusive or - negation a string of digits consisting of 0 through F \ a string of decimal digits followed by '\' % a string of binary digits followed by '%' . the last opened location ' the ASCII value of (which is one character) The only restriction is that the negation operator must be the first operator in the expression. For example, 4*3+-2#7!3 is not legal, while -4*.+'b is legal. Note: While BMP can display numbers in only hexadecimal, numbers may be input as binary, decimal, or hexadecimal. 4 BMP - Binary Maintenance Program *** Deposit Data: *** This is data which is intended to be written out by the user and takes two forms: symbolic and non-symbolic. The symbolic form has the syntax: where the opcode is 'LDAA', 'ORAA', 'TSX', 'CLRA', etc. is absent when the opcode requires no argument; otherwise, it has the form: # or ,X or # indicates immediate addressing; ,X means indexed; just means direct or extended addressing (direct is used if possible). The argument must be separated from the opcode by exactly one space. For example: LDAA 10+45,X The non-symbolic form has the syntax $ or Examples: $101 $10+'a 24+. 5 BMP - Binary Maintenance Program *** Simple commands *** There are a few simple commands which are used most of the time in BMP: / - examine This command examines the contents of location . The data is printed out in the mode specified by the last mode setting command. Note: Because some modes require more than one byte of data, the location specified by the user is used as a starting location. For instance, in the ;X mode, BMP prints out the value of two adjacent bytes. In addition, the next deposit location is set to the address , thereby allowing the user to change the data with the next command. No actual data is changed with this command. Also, the symbol '.' is given the value of , when used in expressions. - close A 'disarms' the next deposit location so that it is no longer valid. Afterwards, should the user try to deposit data without doing a '/' command, he will be chastised with a 'I don't know where to deposit that!' error message. - deposit and close The data is deposited at the next deposit location and a regular command is executed. - examine next Acts as if the user had typed '.+n/' where n is the number of bytes last displayed. Illegal if there is no valid next deposit location. 6 BMP - Binary Maintenance Program - deposit and examine next The data is deposited in the next deposit location and the contents of the location following the deposited data is shown. ^ - examine previous Is identical to '.-1/'. Not legal if there is no valid next deposit location. ^ - deposit and examine previous Is identical to '.-1/'. Not legal if there is no valid next deposit location. = - evaluate expression The equals command merely prints out the value of the expression preceeding it. The value printed out may be used as the first operand in an expression following the '=' just as if the user had typed the value. For example, typing '2+.=xxxx-10/' (where xxxx is printed by BMP) is both legal and useful. ,/ - display multiple locations Starting at , the contents of memory or disk are displayed on the terminal. If is a hex number with less than three digits or is an expression less than 256, locations are displayed through +; otherwise, they are displayed through . If the display mode is ;O, the display is in symbolic format. If the display mode is not ;O, locations are displayed as both hex numbers and ASCII characters. Pressing during the print out will cause the display to abort. 7 BMP - Binary Maintenance Program *** Searching *** BMP will search the designated source for a specified target, using a specified mask to select the bits to be used in the comparison. A list of all locations meeting the search criteria will be displayed. The source is designated by one of the three access modes. The target is specified by ?T and the mask is specified by ?M The current search target and mask may be displayed by ? yielding TARGET = xx MASK = xx The search is initiated by ,?S where and are the lower and upper inclusive bounds of the search. The search mask tells BMP what parts of the target to take seriously; each byte of the mask corresponds to a byte of the target (so the mask must be as long as the target). A bit set to 1 in a mask byte says to ignore that corresponding bit in the byte being compared with the target byte. A bit set to 0 says that the corresponding bit in the byte being compared must match exactly. 8 BMP - Binary Maintenance Program *** Access commands *** ;M All references go to memory after execution of this command. This is the default mode. ;B All locations referenced by the user are translated to disk addresses and the reference made to the specified binary file. If the file contains records which will overlap other records when loaded into memory, BMP directs the reference to the record which would be loaded last. When an examined location is not found in any of the records, the value zero is displayed. When a deposit location does not exist in any of the records, a new record is created. Note: Because of the translation involved in converting a memory address to a disk address, binary mode runs slightly slower than memory or diskdump modes. ;D All references go to the specified disk or disk file. Since BMP and the user can only discuss locations in the range of 0 to 65535, BMP has a provision for dealing with files that have 65536 or more bytes in them. The user is allowed to specify an offset which is added to the user's location to produce an absolute file location. This offset can be specified in either of two forms: a base sector or a base cluster. Thus, if the user wishes to change byte 3E of sector 5F5 to a zero, he need only type 5F5;S 3E/ xx $0 To set the offset to sector , type ';S'. To set it to cluster , type ';C'. An automatic '0,nbps/' is performed upon execution of these commands (nbps is the number of bytes per sector). 9 BMP - Binary Maintenance Program *** Filenames: *** is a valid SDOS file name, including device names. Examples: sdos.sys D0:defaultprogram wd0: *** Information Commands *** Information commands give information about a file or its structure. ;L This command gives a list of load records in the object FILE selected. It is most useful for determining where an object file loads into memory. ;H This command locates the file named in the directory, and displays the displacement into the directory for filename entry and the header cluster of the FILE. The value displayed can be used in conjunction with ;D and xx;C commands to examine the file header cluster. *** Miscellaneous Commands *** ,;C This command computes the sum (modulo 256) of the bytes between the addresses E1 and E2, inclusive. *** Errors *** Most error messages issued by BMP are self explanatory. One, though, may be a bit confusing: 'Are you sure you want to write on the disk DEVICE?' This message occurs when a disk device (not a file) is open in diskdump mode and the user is attempting to do a deposit. This is merely a safety check, and typing 'YES' will pacify BMP. Typing anything else will abort the deposit and issue a disk write-locked error. Error messages printed out are of two varieties: those which have an 'AT LINE xxxx' tacked to the end and those that do not. Those errors which have a line number are issued by SDOS and relate to some I/O problem (like file not found, etc.). Those not followed 10 BMP - Binary Maintenance Program by line numbers are issued by BMP and inform the user that BMP cannot understand or execute the last command. 11 BMP - Binary Maintenance Program *** Sample commands *** To display page zero of memory ;M 0,FF/ To disassemble a block of code between $100 and $25E ;O 100,25E/ To display bytes at 12D3 through 12D3+1E 12D3,1E/ To display $26 through $38 26,0038/ To patch a JSR $100 into location $526 526/ xxxx JSR 100 To patch a BNE $1234 at $1226 1226/ xxxx BNE 1234 To open a binary file ABC for examination/patching ABC;B To patch location 107D to a CLRA 107D/ xxxx CLRA To search for 'fred' or 'FRED' in the range of 12D3 to 12F3 'F'R'E'D?T 20202020?M 12D3,12F3?S To quit: ;E (C040281) 12