home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / distomwc / distomwc.doc next >
Text File  |  1989-01-24  |  8KB  |  171 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.           DISTOMWC:  By Howard C. Johnson
  8.                      30 Roosevelt Ave.
  9.                      Morganville, NJ 07751
  10.  
  11.  
  12.                                        PURPOSE
  13.  
  14.                Disassemble  DRI  formatted  files  to Mark Williams C (MWC)
  15.           assembler directives.  This  produces output  similar to as68toas
  16.           output.   Ideally, output  of distomwc may be assembled to a file
  17.           that is identical to the one being disassembled.
  18.  
  19.                                       HEREDITY
  20.  
  21.                DISTOMWC  was  created  by  disassembling  DIS2ND  by  Scott
  22.           Swintec and  then modifying it.  To be used by MWC, the output of
  23.           dis2nd  must  be  further  processed  by  as68toas.    Four basic
  24.           problems are addressed:
  25.                1. The operand order is reversed for 'eor' instructions.
  26.                2.  Addresses  in  the  data  section  do not become labels,
  27.           producing many undefined symbols.
  28.                3. As68toas does not recognize either short branches (bxx.s)
  29.           or short  addresses (wwww:s).   It  also cannot handle intermixed
  30.           hex and ascii strings.
  31.                4. Data embedded in  the  text  section  is  disassembled as
  32.           meaningless, and often illegal, instructions.
  33.  
  34.                                  DISTOMWC OPERATION
  35.  
  36.           Symbol Table:
  37.  
  38.                Input to  DISTOMWC is a DRI compatible object file.  Several
  39.           assemblers/loaders may produce  load  modules  that  are  not DRI
  40.           compatible.   MWC is one of these.  The principal differences lie
  41.           in handling symbols.  DRI symbols have two properties:
  42.  
  43.                a. The length of the symbol table is in the file header.
  44.                b. Symbol names are a maximum of 8 characters long.
  45.  
  46.           MWC, for example, has 16 character  names and  the length  of the
  47.           symbol table is 0 in the file header.  The program MWTODRI (GEnie
  48.           # 4098), will convert a  MWC  file  to  DRI  symbol  format.   It
  49.           includes source, so that other files can be handled with reasona-
  50.           ble effort.  However, as very few files  worth disassembling have
  51.           symbol tables  attached, it  is not very important to worry about
  52.           symbol handling.
  53.                External variable names are preceded with a '_' in DRI.  MWC
  54.           uses a  trailing '_'  for the same purpose.  All symbol names are
  55.           converted in DISTOMWC.
  56.  
  57.           Backward and Forward References:
  58.  
  59.                All text references  are  resolved  by  processing  the text
  60.           section twice.   Thus  a branch backward will produce a label for
  61.  
  62.  
  63.  
  64.  
  65.  
  66.           the target of the branch.  However, problems occur when  longs in
  67.           the  data  section  reference  otherwise  unreferenced addresses.
  68.           This occurs in 'C' from two constructs:
  69.  
  70.                a. switch (c) { case: .... }
  71.                b. char *list = {"a", "b", ...}
  72.  
  73.           The switch constructs produce text references that must be known.
  74.           Normally these target addresses are not  the object  of a branch,
  75.           but are  preceded by one.  Text processing will add labels to the
  76.           addresses following bra, jmp, and rts  instructions.   This picks
  77.           up most switch constructs.
  78.                Data lists  that are pointers to strings usually proceed the
  79.           string.  All forward references in the data section are resolved.
  80.           A  .long  in  the  data  section  will show up as undefined if it
  81.           reverences an address  preceding  it  that  isn't  preceded  by a
  82.           branch.
  83.  
  84.           Data Embedded In Text:
  85.  
  86.                Some programs  have variables,  and initialized  data in the
  87.           text section rather than  the data  section.   When disassembled,
  88.           this produces both unrealistic instruction and invalid instructi-
  89.           ons.  The human is best at detecting this problem.  The resoluti-
  90.           on is  to introduce a new file, name.emb to allow the operator to
  91.           mark special areas that need exception handling.  Name.emb is the
  92.           same 'name'  as is  being disassembled.  This file may be located
  93.           in either the current directory, or in the same directory  as the
  94.           file being disassembled.
  95.  
  96.           .EMB File:
  97.                The  name.emb  file  allows  three  kinds of addresses to be
  98.           indicated:
  99.  
  100.                1. S lines, such as 's a010' permit labels to be defined.  A
  101.           location that  needs a  label can  be handled  with this.   All S
  102.           lines must be located in the  first part  of the  file before any
  103.           other lines.
  104.                2.  W  lines  such  as  'w  b124  b135'  will cause the text
  105.           addresses within the range, inclusively, to be output as words or
  106.           longs.  The first address must be even, the second must be odd.
  107.                3.  A  lines  such  as  'a  b136  c001'  will cause the text
  108.           addresses within the range,  inclusively, to  be output  as ASCII
  109.           pairs.  The first address must be even, the second must be odd.
  110.  
  111.           W and  A lines  can be intermixed as necessary after any S lines.
  112.           The addresses must increase monotonically.
  113.  
  114.           Longs in Text:
  115.  
  116.                1.  A .long is recognized  in the  text section  because the
  117.           opcode  word   is  a   relocatable  value.     Whenever  this  is
  118.           encountered,  a  .long  will  be  produced,  and  the  symbol  it
  119.           references will be entered into the symbol table.
  120.  
  121.  
  122.  
  123.  
  124.  
  125.                2.   As many instructions are multiple words, .longs may not
  126.           appear until the area in which they are  located is  first marked
  127.           in the name.enb file as W or A.  However, they will become longs,
  128.           overriding the name.emb file.
  129.  
  130.           Special Notes:
  131.  
  132.                1. When a  disassembled  file  is  reassembled  it  will (by
  133.           default) contain a symbol table of all the generated labels.  The
  134.           presence of these symbols may prevent  the program  from running.
  135.           I believe  that this  is caused by symbol table residue producing
  136.           non zero values in the bss (.bssi) section.  This  occurs because
  137.           MWC fails  to indicate  the symbol table size in the file header.
  138.           Stripping the symbols or using the  mwtodri program  will correct
  139.           this.
  140.                2. MWC will not reassemble addresses in the form
  141.                          0x416:s
  142.           which is produced by the disassembler.  It is necessary to equate
  143.           the values to a name, and use the name in the program.  I.e.,
  144.                          my_name = 0x416
  145.                          move  my_name:s, d0
  146.                3. Short ascii lines in the data section may actually be hex
  147.           binary values.   The binary values are output as a comment to the
  148.           ascii lines.  These are suppressed  if the  HEX output  option is
  149.           not used.
  150.                4.  Embedded  ASCII  (or  constants)  can  and  will produce
  151.           nonsense instructions that can  affect other  valid instructions.
  152.           For example,  ASCII produces many b.. instructions whose apparent
  153.           destination address are  added  to  the  symbol  table.   Besides
  154.           producing strange  internal symbols,  absolute address fields can
  155.           become marked as relocatable.   This  in  turn  can  cause really
  156.           strange output.   Further,  some of  these corrupted instructions
  157.           may break  the disassembler,  causing it  to fail  with no useful
  158.           output.   When this  occurs, try  marking the whole text space as
  159.           ASCII in the name.emb file to identify the ASCII areas first.
  160.  
  161.  
  162.  
  163.     A little more now that MWC 3.0 is out.  
  164.  
  165.     1. The symbol table length is now in the header but it still is not
  166.        in DRI format.
  167.     2. Don't throw away the 2.0 version of the MWC assembler.  They 
  168.        broke it in 3.0, and it can not handle addr:s format at all.
  169.  
  170.  
  171.