****************************************************************
*                                                              *
*               D68K DISASSEMBLY TOOLKIT V1.27                 *
*                 COPYRIGHT FRANK SWIFT 1995                   *
*                    ALL RIGHTS RESERVED.                      *
*                                                              *
*       D68K is a BASIC toolkit for disassembling files        *
*       or memory (RAM).                                       *
*                                                              *
****************************************************************


MDIS [#<chan>,]<pc>,[<org><length>]

This procedure disassembles <length> bytes of code at address
<pc>. The disassembly is printed to #<chan> or to #1 if no
channel is specified and is optionally relocated to the address
<org>.

FDIS [#<chan>,]<filename$>,[<pc>,[<org>[<length>]]

This procedure disassembles <length> bytes from the specified
<filename$> at offset <pc>. The disassembly is printed to
#<chan> or to #1 if no channel is specified and is optionally
relocated to the address <org>.

D68K <pc>,[<org><buffer>]

This function disassembles one m/c instruction at address <pc>.
The disassembly is printed as a C string (0 terminated) to an
ASCII buffer at address <buffer> and is optionally relocated to
the address <org>. The function returns the number of bytes
disassembled. You must allocate an ASCII buffer of at least 256
bytes before using this function.


***************************************************************
*                                                             *
*                   ADVANCED USER INFORMATION                 *
*                                                             *
***************************************************************


EXTERNAL LINKS TO THE DISASSEMBLER

D68K makes use of an entry in the THING list that allows access
to D68K routines that disassemble a single-line of code.

Currently D68Ks' THING is 64 bytes long and contains the
following entries:

Offset   Value    meaning

$26      '1.06'   version number
$2A      4        name length
$2C      'd68k'   name
$30      'THG%'   thing variables follow
$34      2        freeform shared code
$38      ?        address of a 256 byte buffer
$3C      ?        address of single-line disassembly routine

----------------------------------------------------------------

FINDING D68Ks' THING ENTRY

The following machine code could be employed to find D68ks'
THING entry. It returns with the address of the thing in A4.

 Entry: none

 Exit:  A0 = corrupted (address of system variables)
        A4 = address of D68ks' thing entry or zero
        D0 = corrupted
        D1 = corrupted (current job)
        D2 = corrupted (QDOS version)

FIND_THG:
         moveq    #MT.INF,d0        ; find system variables
         trap     #1

         lea      $B8(a0),a4        ; start of THING list

NEXT_THG:
         move.l   (a4),d0
         move.l   d0,a4
         beq.s    EXIT              ; exit if not found

         cmp.w    #4,$2A(a4)        ; compare name length
         bne.s    NEXT_THG

         cmp.l    #'d68k',$2C(a4)   ; compare name
         bne.s    NEXT_THG

EXIT:
         rts

----------------------------------------------------------------

SINGLE-LINE DISASSEMBLY ROUTINE

 Entry: A0 = <pc>
        A1 = <org>
        A2 = 256 byte ASCII buffer

 Exit:  A0 = updated pc
        A1 = updated org
        A2 = updated buffer
        d0 = number of bytes disassembled

The routine pointed to by offset $3C in D68ks' THING entry
disassembles one m/c instruction at address <pc>. The
disassembly is stored as a C string (0 terminated) in an ASCII
buffer and is optionally relocated to the address <org>. The
routine returns the number of bytes disassembled in d0.

You should allocate your own buffer as the one pointed to by
offset $38 may not be usable.

****************************************************************
