Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

CUG New Releases


July 1995/CUG New Releases

CUG New Releases

m68kdis

Victor R. Volkman


Victor R. Volkman received a BS in Computer Science from Michigan Technological University. He has been a frequent contributor to C/C++ Users Journal since 1987. He is currently employed as Senior Analyst at H.C.I.A. of Ann Arbor, Michigan. He can be reached by dial-in at the HAL 9000 BBS (313) 663-4173 or by Usenet mail to sysop@phal 9k.com.

CUG #430: m68kdis Motorola 68000 Family Disassembler

Christopher G. Phillips (University of Texas at Austin) submits his m68kdis disassembler for the Motorola 68000 family of CPU chips. Disassemblers are system software packages that accept a binary executable as input and produce assembly language source as output. Specifically, m68kdis supports the full instruction sets of the 68000, 68008, 68010, 68020, and 68030 CPU chips. Additionally, m68kdis decodes instructions for the 68851 Paged Memory Unit and the 68881/68882 Floating-Point Coprocessors. The Motorola 68000 family chips power millions of computers, including the Macintosh, Atari, Amiga, and many embedded CPUs in industrial applications. The CUG Library edition of m68kdis includes full source in C (no executables are provided). The m68kdis disassembler is immediately available as CUG volume #430. (For a list of related CUG products see the sidebar.)

Since m68kdis is portable, it is actually a cross-disassembler. For example, you can disassemble 68000 programs on a variety of host CPUs, from PCs to UNIX machines. Phillips provides a very clean makefile without any OS-specific flags or options. Additionally, he takes care to avoid common pitfalls such as dependencies on the size of the int data type.

Using m68kdis

In its basic operation, m68kdis reads in a single binary file (.o) and produces an ASCII file containing an assembly language output (.s). Ideally, you could then run the .s file through your assembler and it would produce an .o file identical to the original. Strictly speaking, a disassembler is just a subset of the functionality found in a debugger. The output of m68kdis is divided into five distinct columns: program counter, file contents, label, instruction, and operands (see Figure 1) .

Programmers often use disassemblers in two specific modes of operation. First, a one-shot run can check the operation of a compiler, the validity of an executable, the executable startup code, or perform a similar examination. Second, the programmer may use a sophisticated disassembler such as m68kdis in several successive iterations. In this cycle, the programmer uses his own judgement to help separate blocks of instructions from blocks of data. Then he applies his knowledge or guesswork so that the next iteration provides clearer output. With persistence, a usable source file can result.

m68kdis supports this iterative method by providing options (see Table 1) for the import of separate files containing external knowledge of the input file. For example, the -i file option causes m68kdis to read an ASCII file containing addresses at which instructions are known to start. Similarly, you can create files of addresses where data is known to reside. (A small improvement to m68kdis would allow ranges of addresses instead of just singleton addresses in the file.)

Macintosh Support

Although m68kdis works equally well against any target 68000 executable, the author includes special additional support for Macintosh executables. m68kdis understands enough of the executable to follow the resource fork and dump it in a readable fashion. This insures more reliable output because determining the difference between instructions and data is the prime job of a disassembler.

m68kdis supplies files containing Macintosh A-line instructions and their OS equivalent entry point names. More than 800 A-line instructions can be decoded in this manner. These entry points are somewhat analogous to BIOS interrupt (INT) instructions used on Intel-based MS-DOS PCs.

This volume also includes a series of Perl scripts, which perform post-processing on the disassembler output. (Perl is not included in the CUG Library distribution, but is widely available on the Internet.)

Documentation, Licensing, and Support

Documentation for m68kdis consists primarily of a five-page summary that appears in UNIX "man" page format. As such, the documentation primarily details command-line options and usage. For insights into disassembly algorithms, you'll need to follow the comments in the code. For details on the 68000 family instructions sets, please see the section named "Further Reading" below.

Phillips includes an extremely generous license that extends the permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee. His only restriction is that his supplied copyright notice appear in all copies of software and that both the copyright notice and the permission notice appear in supporting documentation.

Since m68kdis is freeware, there are no formal support options available. Support is thus necessarily limited to email correspondence regarding bugs and enhancement requests. You can contact Chris at [email protected].

For Further Reading

For those interested in how 68000 family instructions are encoded, Prentice-Hall (Englewood Cliffs, NJ) publishes a complete line of databooks. Here are some of the titles that Phillips cites:

Motorola. M68000 8/16/32 Bit Microprocessors: Programmer's Reference Manual, 5th Edition.

Motorola. M68030: Enhanced 32-Bit Microprocessor User's Manual, 2nd Edition.

Motorola. M68851: Paged Memory Management Unit User's Manual, 2nd Edition.

Motorola. M68881/MC68882: Floating-Point Coprocessor User's Manual, 2nd Edition.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.