GitXplorerGitXplorer
c

m68kdis

public
9 stars
2 forks
0 issues

Commits

List of commits on branch master.
Unverified
27d1528fb8b84f33a073301e327d71831cfd2639

Add README.md for Github.

ccr1901 committed 6 years ago
Unverified
4263aca9d67960f5d7bb893840b1c8bf5ca95860

Initial commit of all unmodified files.

ccr1901 committed 6 years ago

README

The README file for this repository.

m68kdis

Prelude

This software was not originally made by me. It was originally written in 1994 by one Christopher G. Phillips. AFAICT, it was originally submitted to Dr. Dobb's Journal in 1995. Other than that and some sparse Usenet postings, I have no information on the original author.

Unlike most non-commercial assemblers, m68kdis can automatically infer code and data in raw binary images. It is also extremely portable being written in only ANSI C. If that's not your cup of tea, perhaps bindings can be extracted for interactive use cases? I might even do it at some point :).

After thinking I lost my original copy, and not finding the source on Github, I decided to upload a fresh copy. On Windows 7, it compiles as-is if gcc is installed, and probably works fine with MSVC as well. I personally downloaded my copy from the Raine emulator website, and commited a copy that was last lightly modified in 2002.

The manual, converted from mandoc into HTML (expect formatting errors), follows below.

Manual

M68KDIS

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
NOTES
BUGS
SEE ALSO
AUTHOR


NAME

m68kdis − disassemble Motorola 68000 family object code

SYNOPSIS

m68kdis [ddd] [−a file] [−all[c]] [−b file] [−bad] [−f file] [−i file] [−j file] [−l] [−lft] [−n file] [−ns file] [−o file] [−odd] [−pc initialpc] [−s length] [−slenp length] [−sp] file...

DESCRIPTION

m68kdis is a disassembler for the Motorola 68000 family of cpu chips. The disassembler attempts to discern between the instruction and data portions of an object code file.

m68kdis produces output files much like cc(1). When the −o option is not used, file arguments that end in .o have output filenames with .s substituted for .o; otherwise, .s is simply appended.

The output consists of five columns:

program counter in hexadecimal

file contents with each byte displayed as two characters in hexadecimal

label (if any)

instruction name

operands (if any)

OPTIONS

−ddd

Specifies the chip and coprocessors. Valid values for ddd are currently 000, 008, 010, 020, 030, 851, 881, and 882. This option may be repeated as appropriate. The default is 000 with no coprocessors.

−a file

Specifies that file contains lines of the form ‘‘aXXX instruction−string’’ which specify acceptable A-line opcodes. XXX is in hexadecimal.

−all[c]

Specifies that only one pass should be made, outputting the instruction (if any) at each word boundary. If the c is included, −i, −j, −n and −ns options are also processed, and another pass is made to ensure consistency between instructions.

−b file

Specifies that file contains program counter values which are taken as locations in data to be output on a new line. The values should be one to a line, and of a form acceptable to strtoul() with base equal to 0.

−bad

Specifies that lines should be printed to standard error that specify which data caused a potential instruction to be made invalid.

−f file

Specifies that file contains lines of the form ‘‘fXXX instruction−string’’ which specify acceptable F-line opcodes. XXX is in hexadecimal.

−i file

Specifies that file contains program counter values which are, if possible, to be taken as locations of valid instructions. The values should be one to a line, and of a form acceptable to strtoul() with base equal to 0.

−j file

Specifies that file contains A-line and F-line opcodes which are unconditional jumps and therefore do not need to be followed by a valid instruction. The values should be one to a line, and of a form acceptable to strtoul() with base equal to 0.

−l

Specifies that output should be in lower-case. (Exception: Label references retain an upper-case ‘‘L’’.)

−lft

Specifies that instructions that ‘‘fall through’’ to a LINK instruction should be considered valid. By default, these instructions are considered invalid.

−n file

Specifies that file contains program counter values which are to be taken as locations of data. The values should be one to a line, and of a form acceptable to strtoul() with base equal to 0.

−ns file

Specifies that file contains program counter values which are to be taken as locations at which instructions do not begin. The words at these locations may, however, be extension words of instructions. The values should be one to a line, and of a form acceptable to strtoul() with base equal to 0.

−o file

Specifies the output file. Only one file to be disassembled may be given when this option is used.

−odd

Specifies that instructions may begin at odd offsets. This can be useful when code to be disassembled is not stripped out of an object file. In particular, this option is often needed when disassembling an intact Macintosh resource fork.

−pc initialpc

Specifies that initialpc be taken as the program counter value for the start of the object code. The default is 0.

−s length

Specifies that data contain at least length consecutive printable characters to be output as a string. The minimum value for length is 2; the default is 5.

−slenp length

Specifies that strings should print out no more than length characters per output line. The minimum value for length is 10; the default is 30.

−sp

Specifies that register A7 should be output as SP, except in MOVEM instructions.

NOTES

The output is based on Motorola syntax.

Immediate values are sometimes also output in hexadecimal after an intervening !.

The following procedure is used to filter out the data from the instructions:

An initial pass is made determining at which file offsets potential instructions exist and the sizes of those instructions including operands.

File offsets specified by the user as being data are processed.

File offsets specified by the user as not starting instructions are processed.

File offsets specified by the user as being instructions are processed.

Potential instructions which reference data as instructions are changed to data. (This step is repeated after each of the remaining steps.)

LINK instructions which are referenced by BSR and JSR instructions are accepted as final instructions. (A final instruction is one that is included in the final output.)

Remaining LINK instructions are accepted as final instructions.

Branching and jumping instructions that reference final instructions and are not potential extension words of floating-point instructions are accepted as final instructions.

Remaining branching and jumping that are not extension words of potential floating-point instructions and returning instructions are accepted as final instructions.

Overlapping instructions are selected by minimizing the amount of data.

BUGS

You will probably need 16-bit shorts and 32-bit ints.

Since m68kdis uses the imperfect procedure given in the NOTES , errors may result in the instruction/data determination. When problems are suspected, the −badX option can be used to determine why instructions get interpreted as data. You can then use the −i, −ns, and −n options, as appropriate.

Two unusual conditions checked for should be mentioned. Sometimes the decision to designate an instruction as a final instruction is later contradicted and the instruction is changed to data. In general, the instruction causing the contradiction should be regarded as data via the −ns option. Also, sometimes it is reported that there is an ‘‘overlap’’ at a certain offset. This is because m68kdis is unsure if the best selection of two possible instructions which overlap each other was made. A quick inspection of the output at this offset should clear this up. Messages for these conditions are printed to standard error.

SEE ALSO

1.

Motorola: M68000 8/16/32 Bit Microprocessors: Programmer’s Reference Manual, 5th ed., Prentice-Hall, Englewood Cliffs, NJ, 1986.

2.

Motorola: M68030: Enhanced 32-Bit Microprocessor User’s Manual, 2nd ed., Prentice-Hall, Englewood Cliffs, NJ, 1989.

3.

Motorola: M68851: Paged Memory Management Unit User’s Manual, 2nd ed., Prentice-Hall, Englewood Cliffs, NJ, 1989.

4.

Motorola: M68881/MC68882: Floating-Point Coprocessor User’s Manual, 2nd ed., Prentice-Hall, Englewood Cliffs, NJ, 1989.

AUTHOR

Christopher G. Phillips
Christopher_Phillips@pe.utexas.edu