home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 283.lha / ReSource_v3.01_Demo / Introduction.doc < prev    next >
Encoding:
Text File  |  1989-09-07  |  37.8 KB  |  901 lines

  1.                      Introduction to ReSource
  2.      
  3.                  ReSource (C) 1988 Glen McDiarmid
  4.       
  5.      The documentation for ReSource is in two parts.  This is the
  6.      introduction, the other is the specifications for each
  7.      function, in the order in which they appear in the menus.
  8.      
  9.      Because ReSource uses functions in the "ARP" library, you
  10.      must have the file "arp.library" in your "LIBS:" directory
  11.      when you run ReSource.  This file is supplied with both the
  12.      demo and commercial versions of ReSource, and is available
  13.      from most BBS's.  The version of "arp.library" must be 34 or
  14.      higher.
  15.      
  16.      Because of the large number of functions in ReSource, it was
  17.      decided to use one-and two-character menu names, so that
  18.      more menus could be used.  Looking from the left, the first
  19.      menu is "P", which stands for "PROJECT".  The real menu name
  20.      is directly under the one-or two-character name, in capital
  21.      letters, so should be fairly easy to find them.  In all
  22.      future reference to menus, the full menu name will be used.
  23.      
  24.      When describing a function, rather than telling you what key
  25.      to press to get that function, I'll describe where abouts in
  26.      the menus that you will find that function.  For example,
  27.      the "Quit" function would be described as "PROJECT/Quit". 
  28.      The function to restore the current file would be "PROJECT/
  29.      Restore".  You will find both of these under the "PROJECT"
  30.      menu.  Functions in sub-menu boxes will be described in a
  31.      similar way, i.e. "OUTPUT/Tabs/Spaces".  Because any key can
  32.      have any function bound to it (except "PROJECT/Abort"), key
  33.      usage will not be discussed, when referencing functions. 
  34.      However, to make it easier to get started, some key bindings
  35.      will be present, even without loading a keytable:
  36.      
  37.      up arrow..............................scroll up one line
  38.      down arrow............................scroll down line line
  39.      shift-up arrow........................page backwards
  40.      shift-down arrow......................page forward
  41.      right arrow...........................forward reference
  42.      left arrow............................previous location
  43.      right-Amiga Q.........................quit
  44.      right-Amiga O.........................open a file
  45.      
  46.      To rebind a key, select "KEY BINDINGS/Rebind key" from the
  47.      menus, select a function from the menus to have bound, then
  48.      press the key that you want it bound to.  You can overwrite
  49.      key bindings if you want.  When done, you should save the
  50.      keytable as "RS.keytable".  This can be done by selecting
  51.      "KEY BINDINGS/Save" from the menus.  Even both of these
  52.      functions can be bound to a key, in fact the only function
  53.      that is not practical to rebind is "PROJECT/Abort", which is
  54.      always bound to right-Amiga A.
  55.      
  56.      Many functions in ReSource operate only on the current line.
  57.      Because there is no real "cursor", it is necessary to define
  58.      the "current line":
  59.      
  60.  
  61.  
  62.      >> The "current line" is the top line, as you see it in
  63.      ReSource's screen.  There may be a section statement to be
  64.      displayed for the cursor address, this will be shown before
  65.      the other text, and will force it to be shown on the next
  66.      line down.  If this is not the first section statement in
  67.      the program, there will be an extra blank line, which will
  68.      be shown before the section statement.  After the section
  69.      statement, and before the rest of the line, one or more
  70.      "full-line comments" can be attached.  Immediately after the
  71.      cursor line, any "hidden labels" will be shown.  A hidden
  72.      label may also have a full-line comment attached, which will
  73.      be shown immediately before it, but after the cursor line. 
  74.      Whenever you scroll up or down a line, all parts of the
  75.      "current line" will scroll up together, which may be
  76.      sometimes be visually jarring, if there is many extra lines
  77.      of text attached.  To put it simply, the first "real" line
  78.      of code or data in the window is the current line.
  79.      
  80.      PURPOSE:
  81.      ReSource was originally just an interactive disassembler,
  82.      but Version 2 is much more than this.  Because ReSource can
  83.      get its' input from a file, track, or memory, and output all
  84.      or part to any of these, it is more of a general purpose
  85.      hacking tool.  It can be used to browse through files,
  86.      without ever bothering to save anything, just to find out
  87.      what is inside.  When you run ReSource, you cannot do
  88.      anything until you give it something to work on.  You can
  89.      supply the name of the file to load in on the command line:
  90.      
  91.      run resource c:popcli
  92.      
  93.      Alternatively, you can wait until ReSource starts running,
  94.      and select a file using the file requester.  For full
  95.      specifications on command line parameters, see below. 
  96.      Providing that there is enough memory available, you can
  97.      load ANY file into ReSource.  If ReSource recognizes it as a
  98.      load file (one that you can run; an executable program), it
  99.      will load it, perform any necessary relocation, etc., as if
  100.      the program is going to be actually run.  If the file that
  101.      you request loaded is not a load file, it will be loaded "as
  102.      is".  Load files may be also loaded "as is", by using the
  103.      "Load binary" function, in the "PROJECT" menu.  This will
  104.      give you access to the hunk, symbol, and relocation
  105.      information, that otherwise gets stripped out when the
  106.      program is loaded into memory.  Libraries, devices drivers,
  107.      fonts are also load files, which means that you can
  108.      disassemble them, save the assembler source code, do a
  109.      modification, and re-assemble them.
  110.      
  111.      DISASSEMBLING A PROGRAM:
  112.      To disassemble a program is to interpret what went into the
  113.      program, to make it work.  It can be a very complex and
  114.      trying task, with practice one can become quite adept at it.
  115.      There is many different and seperate things to do when
  116.      disassembling, one of the most important things is to
  117.      seperate the code from the data.  There is only one part of
  118.      a load file that is guaranteed to be code, and that is at
  119.      the very start.
  120.      
  121.  
  122.  
  123.      ReSource has the ability to scan lines of code, looking for
  124.      references to other parts of the program being disassembled.
  125.      This is a very useful function, as when a reference is made,
  126.      it creates a label at that address, which will be used in
  127.      all future references to that part of the program, no matter
  128.      where it is referenced from.  Even more importantly,
  129.      ReSource can determine what type of data is being
  130.      referenced, and be correct (almost) every time.  If you
  131.      intend to reassemble the code, you should still verify the
  132.      source before saving it, as mistakes will occur from time to
  133.      time.  Before ReSource makes a decision about what type of
  134.      data is being referenced, it examines many different pieces
  135.      of information that is available, including the actual
  136.      instruction that made the reference.  There is a few ways of
  137.      getting ReSource to scan lines of code.  The simplest way is
  138.      by using the "LABELS/Create single/Label - dest".  This
  139.      scans only the current line, and does NOT advance the cursor.
  140.      
  141.      If, in a line of code, a reference is made to somewhere
  142.      within the program, that HASN'T got a label yet, it will be
  143.      shown as some offset from the label "START", which is
  144.      imagined to be (but not actually, unless YOU have done it)
  145.      attached to the first byte in the program.  You could create
  146.      a label called "START", at the first byte in the program,
  147.      however when you re-assemble, there is a chance that some
  148.      different length instructions will be used, which will make
  149.      all references past the first different instruction,
  150.      inaccurate.
  151.      
  152.      Another way to get ReSource to scan lines of code is with
  153.      the "LABELS/Create multiple/ALL".  This function scans the
  154.      current line, and if ReSource is reasonably sure that it is
  155.      really code, it will scan it, and move on to the next line. 
  156.      This process will repeat until either the end of file, or
  157.      until ReSource believes that the current line may not be
  158.      code, even though it may be displaying as such. After
  159.      executing this function, if the cursor isn't at the end of
  160.      file yet, and there is some more code that hasn't been
  161.      "scanned" yet, you can scroll to the start of the next block
  162.      of code, and execute this function again, repeating until
  163.      all code in the program has been scanned.  At this point,
  164.      most references within the program will be to labels, and
  165.      not use the "START+$xxxx" type of reference.  To make sure
  166.      of this, you can set up a search for "START+", and perhaps
  167.      scan the lines individually.
  168.      
  169.      When all code in a program has been "scanned", generally the
  170.      next function that you will want to use is "DISPLAY/Fill-in
  171.      data types".  This function does two passes over the entire
  172.      program, and does NOT shift the cursor.  The first pass
  173.      looks at what data types have been set, and makes some
  174.      assumptions for all places in the program where the data
  175.      type has not been specifically set.  When you "Set data
  176.      type", you are telling ReSource "this is CODE", or "this is
  177.      ASCII", or "these are to be displayed as bytes", etc. 
  178.      Generally, this data type will be assumed from this byte
  179.      forward, until the next byte that has had the data type
  180.      specifically set.  Many conditions are tested when making
  181.      decisions about what type of data is where, providing that
  182.      you have "scanned" all code in the program, after executing
  183.      the "Fill-in data types" function, the resulting source code
  184.      will look like source code should look.
  185.  
  186.  
  187.      
  188.      The second pass in "Fill-in data types" is called
  189.      "Calculating line lengths" in the title bar.  This is used
  190.      to let ReSource know how far back to go, when scrolling
  191.      backwards.  Also, string lengths are determined during this
  192.      pass.  When you first load in a file, all line lengths are
  193.      set to two bytes.  When scrolling forward, most things will
  194.      be shown properly anyway, but if you scroll backwards before
  195.      first doing a "Fill-in data types", a jarry display will
  196.      result.
  197.      
  198.      At this point, if you output to a ".asm" file, it will
  199.      probably be good enough to re-assemble.  However, most
  200.      people will want to examine the file, and make it more
  201.      readable, especially if the program needs to be modified. 
  202.      An excellent place to start is by finding where any
  203.      libraries are being opened, finding where the library base
  204.      is being stored, and give meaningful names to these data
  205.      storage locations.  Assume that the following code is a
  206.      small part of a program:
  207.      
  208.              MOVE.L  4,A6
  209.              LEA     START+$06B6(PC),A1
  210.              JSR     -$0198(A6)
  211.              MOVE.L  D0,START+$0C36
  212.              BNE.S   START+$06AE
  213.              MOVE.L  #$00038007,D7
  214.              JSR     -$006C(A6)
  215.              BRA.S   START+$06B2
  216.       
  217.              JSR     START+$0142
  218.              ADDQ.W  #8,SP
  219.              RTS     
  220.       
  221.              BCC     START+$0727
  222.              ????    
  223.              BGE     START+$0725
  224.              BHI     START+$0730
  225.              BSR     START+$0732
  226.              ????    
  227.      After scanning all code in this program, it would look like
  228.      this:
  229.              MOVE.L  4,A6
  230.      lbC000694       LEA     doslibrary.MSG(PC),A1
  231.              JSR     -$0198(A6)
  232.              MOVE.L  D0,START+$0C36
  233.              BNE.S   lbC0006AE
  234.              MOVE.L  #$00038007,D7
  235.              JSR     -$006C(A6)
  236.              BRA.S   lbC0006B2
  237.       
  238.      lbC0006AE       JSR     lbC000142
  239.      lbC0006B2       ADDQ.W  #8,SP
  240.              RTS     
  241.  
  242.      doslibrary.MSG  dc.b    'do'
  243.              dc.b    's.'
  244.              dc.b    'li'
  245.              dc.b    'br'
  246.              dc.b    'ar'
  247.              dc.b    'y',0
  248.  
  249.  
  250.       
  251.      Next, "DISPLAY/Fill-in data types" will be used:
  252.      
  253.              MOVE.L  4,A6
  254.      lbC000694       LEA     doslibrary.MSG(PC),A1
  255.              JSR     -$0198(A6)
  256.              MOVE.L  D0,lbL000C36
  257.              BNE.S   lbC0006AE
  258.              MOVE.L  #$00038007,D7
  259.              JSR     -$006C(A6)
  260.              BRA.S   lbC0006B2
  261.       
  262.      lbC0006AE       JSR     lbC000142
  263.      lbC0006B2       ADDQ.W  #8,SP
  264.              RTS     
  265.      doslibrary.MSG  dc.b    'dos.library',0
  266.      
  267.      The astute will have noticed that because the A6 register
  268.      was loaded from location 4, it will point to the exec
  269.      library base.  Therefore, the third line of this block of
  270.      code is a call to somewhere in the exec library.  By
  271.      scrolling so that this line becomes the top line on the
  272.      screen, and selecting the "SYMBOLS/Libraries/Exec", our
  273.      block of code will look like this:
  274.      
  275.              MOVE.L  4,A6
  276.      lbC000694       LEA     doslibrary.MSG(PC),A1
  277.              JSR     _LVOOldOpenLibrary(A6)
  278.              MOVE.L  D0,lbL000C36
  279.              BNE.S   lbC0006AE
  280.              MOVE.L  #$00038007,D7
  281.              JSR     -$006C(A6)
  282.              BRA.S   lbC0006B2
  283.       
  284.      lbC0006AE       JSR     lbC000142
  285.      lbC0006B2       ADDQ.W  #8,SP
  286.              RTS     
  287.      doslibrary.MSG  dc.b    'dos.library',0
  288.       
  289.      Checking the documentation for the "OldOpenLibrary" exec
  290.      call will tell us that on return, the D0 register will
  291.      contain the library base for the library just opened, if
  292.      successful.  Because we know that it was the DOS library
  293.      that was opened, the label "lbL000C36" referenced on the
  294.      fourth line could now be called "Dos_Base", instead of
  295.      "lbL000C36":
  296.   
  297.              MOVE.L  4,A6
  298.      lbC000694       LEA     doslibrary.MSG(PC),A1
  299.              JSR     _LVOOldOpenLibrary(A6)
  300.              MOVE.L  D0,Dos_Base
  301.              BNE.S   lbC0006AE
  302.              MOVE.L  #$00038007,D7
  303.              JSR     -$006C(A6)
  304.              BRA.S   lbC0006B2
  305.       
  306.      lbC0006AE       JSR     lbC000142
  307.      lbC0006B2       ADDQ.W  #8,SP
  308.              RTS     
  309.      doslibrary.MSG  dc.b    'dos.library',0
  310.  
  311.  
  312.      
  313.      If the D0 register DID contain a non-zero value, it means
  314.      that "dos.library" did open successfully, and the following
  315.      conditional branch WILL be taken.  Where this branches to,
  316.      is labelled "lbC0006AE".  A better name for this would be
  317.      "DosOpenedOkay".  Scroll so that the line "lbC0006AE JSR
  318.      lbC000142" is on the top line of the display, and select
  319.      "LABELS/Create single/Label".  When requested, type in
  320.      "DosOpenedOkay":
  321.      
  322.              MOVE.L  4,A6
  323.      lbC000694       LEA     doslibrary.MSG(PC),A1
  324.              JSR     _LVOOldOpenLibrary(A6)
  325.              MOVE.L  D0,Dos_Base
  326.              BNE.S   DosOpenedOkay
  327.              MOVE.L  #$00038007,D7
  328.              JSR     -$006C(A6)
  329.              BRA.S   lbC0006B2
  330.       
  331.      DosOpenedOkay   JSR     lbC000142
  332.      lbC0006B2       ADDQ.W  #8,SP
  333.              RTS     
  334.       
  335.      doslibrary.MSG  dc.b    'dos.library',0
  336.      
  337.      If the call to "OldOpenLibrary" was unsuccessful, the branch
  338.      on the fifth line would NOT be taken.  In this case, the D7
  339.      register is loaded with the value "$38007", and a call is
  340.      made to the subroutine at offset -$6C from where the A6
  341.      register is currently pointing to.  We do know that the A6
  342.      register was pointing to the Exec library base before, we
  343.      also know that none of the code executed so far has
  344.      destroyed the value in A6, so we can safely assume that A6
  345.      will still point to Exec library base.  Hence, by scrolling
  346.      so that the seventh line of this block is on the top line of
  347.      the display, and selecting "SYMBOLS/Libraries/Exec" again,
  348.      our block will look like this:
  349.      
  350.              MOVE.L  4,A6
  351.      lbC000694       LEA     doslibrary.MSG(PC),A1
  352.              JSR     _LVOOldOpenLibrary(A6)
  353.              MOVE.L  D0,Dos_Base
  354.              BNE.S   DosOpenedOkay
  355.              MOVE.L  #$00038007,D7
  356.              JSR     _LVOAlert(A6)
  357.              BRA.S   lbC0006B2
  358.       
  359.      DosOpenedOkay   JSR     lbC000142
  360.      lbC0006B2       ADDQ.W  #8,SP
  361.              RTS     
  362.       
  363.      doslibrary.MSG  dc.b    'dos.library',0
  364.      
  365.      After reading the documentation for the exec call "Alert",
  366.      we find out that on entry, the D7 register should contain a
  367.      number representing an alert code.  By scrolling so the the
  368.      line "MOVE.L #$00038007,D7" is on the top line of the
  369.      display, and selecting "SYMBOLS/A-B/Alert codes", our block
  370.      will now look like this:
  371.  
  372.  
  373.      
  374.              MOVE.L  4,A6
  375.      lbC000694       LEA     doslibrary.MSG(PC),A1
  376.              JSR     _LVOOldOpenLibrary(A6)
  377.              MOVE.L  D0,Dos_Base
  378.              BNE.S   DosOpenedOkay
  379.              MOVE.L  #AT_Recovery!AG_OpenLib!AO_DOSLib,D7
  380.              JSR     _LVOAlert(A6)
  381.              BRA.S   lbC0006B2
  382.       
  383.      DosOpenedOkay   JSR     lbC000142
  384.      lbC0006B2       ADDQ.W  #8,SP
  385.              RTS     
  386.       
  387.      doslibrary.MSG  dc.b    'dos.library',0
  388.      
  389.      Examining the include file "exec/alerts.i" will tell us that
  390.      "AT_Recovery" is used for recoverable alerts, "AG_OpenLib"
  391.      means that a library failed to open, and "AO_DOSLib" tells
  392.      us which library is in question.  Because this is a
  393.      recoverable alert, the following line of code ("BRA.S
  394.      lbC0006B2") WILL be executed, in which case we could change
  395.      the label "lbC0006B2" to something like "DosDidntOpen", or
  396.      "NoDosAvailable".  This is important, as if any other code
  397.      in this program makes a reference to one of the labels that
  398.      we have changed, it too will use the new name.  In this
  399.      example, another part of the program that WAS:
  400.      
  401.      lbC0007DE       MOVE.L  4(SP),D1
  402.              MOVE.L  lbL000C36,A6
  403.              JMP     -$0024(A6)
  404.       
  405.      lbC0007EA       MOVE.L  D4,-(SP)
  406.              MOVEM.L 8(SP),D1-D4
  407.              MOVE.L  lbL000C36,A6
  408.              JSR     -$008A(A6)
  409.              MOVE.L  (SP)+,D4
  410.              RTS     
  411.       
  412.      lbC0007FE       MOVE.L  4(SP),D1
  413.              MOVE.L  lbL000C36,A6
  414.              JMP     -$007E(A6)
  415.       
  416.      And now will be shown as:
  417.      
  418.      lbC0007DE       MOVE.L  4(SP),D1
  419.              MOVE.L  Dos_Base,A6
  420.              JMP     -$0024(A6)
  421.       
  422.      lbC0007EA       MOVE.L  D4,-(SP)
  423.              MOVEM.L 8(SP),D1-D4
  424.              MOVE.L  Dos_Base,A6
  425.              JSR     -$008A(A6)
  426.              MOVE.L  (SP)+,D4
  427.              RTS     
  428.       
  429.      lbC0007FE       MOVE.L  4(SP),D1
  430.              MOVE.L  Dos_Base,A6
  431.              JMP     -$007E(A6)
  432.      
  433.  
  434.  
  435.      After using the function "SYMBOLS/Libraries/Dos" a few
  436.      times, it would become:
  437.      
  438.      lbC0007DE       MOVE.L  4(SP),D1
  439.              MOVE.L  Dos_Base,A6
  440.              JMP     _LVOClose(A6)
  441.       
  442.      lbC0007EA       MOVE.L  D4,-(SP)
  443.              MOVEM.L 8(SP),D1-D4
  444.              MOVE.L  Dos_Base,A6
  445.              JSR     _LVOCreateProc(A6)
  446.              MOVE.L  (SP)+,D4
  447.              RTS     
  448.       
  449.      lbC0007FE       MOVE.L  4(SP),D1
  450.              MOVE.L  Dos_Base,A6
  451.              JMP     _LVOCurrentDir(A6)
  452.       
  453.      To continue, we would replace a few labels:
  454.       
  455.      CloseSUB        MOVE.L  4(SP),D1
  456.              MOVE.L  Dos_Base,A6
  457.              JMP     _LVOClose(A6)
  458.       
  459.      CreateProcSUB   MOVE.L  D4,-(SP)
  460.              MOVEM.L 8(SP),D1-D4
  461.              MOVE.L  Dos_Base,A6
  462.              JSR     _LVOCreateProc(A6)
  463.              MOVE.L  (SP)+,D4
  464.              RTS     
  465.       
  466.      CurrentDirSUB   MOVE.L  4(SP),D1
  467.              MOVE.L  Dos_Base,A6
  468.              JMP     _LVOCurrentDir(A6)
  469.       
  470.      Okay, so far so good.  Now, where the line:
  471.      
  472.              JSR     lbC0007FE
  473.      
  474.      used to be, it would be replaced by:
  475.      
  476.              JSR     CurrentDirSUB
  477.      
  478.      This happens automatically, whenever you replace any label. 
  479.      The process helps itself; the start is the hardest, the rest
  480.      come fairly easily.
  481.      
  482.      In general, where a label is used, if you have any idea of
  483.      what is happening at all, you should replace it with a label
  484.      that will remind you of what the code is doing.  It doesn't
  485.      matter what name you use (as long as it is a legal label for
  486.      the assembler that you plan to use), if necessary you can
  487.      replace it with something better later on.
  488.      
  489.  
  490.  
  491.      MENUS:
  492.      
  493.      The menus in ReSource fully support drag-selecting, and
  494.      multiple selection.  Many options within ReSource have a
  495.      "checked" menu, which in most cases is "hot".  This means
  496.      that even though ReSource may be busy doing something, if
  497.      you select something in the menus that will effect the
  498.      current operation, it will take effect IMMEDIATELY.  For
  499.      example, while saving the source code to a ".asm" file, if
  500.      you select "OPTIONS/SYMBOL/OFF", from that point on, the
  501.      output file will not show any symbols.  Similarly, if you
  502.      selected "OPTIONS/DCB statements/ON" during the save, DCB
  503.      statements would be used in the output file from that point
  504.      on.  This feature is handy during the execution of macros,
  505.      as you will see in the section on macros.
  506.      
  507.      ***********************************************************
  508.      
  509.      KEYS:
  510.      
  511.      As mentioned previously, any function except the "PROJECT/
  512.      Abort" function can be bound to any key.  All non-qualifier
  513.      keys can be used, with or without any of the following
  514.      combinations of qualifier keys:
  515.      
  516.      shift (left or right, or caps lock, all treated as one)
  517.      alt   (left or right, both treated as one)
  518.      ctl
  519.      left Amiga
  520.      right Amiga
  521.      shift-alt
  522.      shift-ctl
  523.      alt-ctl
  524.      shift-alt-ctl
  525.      
  526.      For example, to rebind the "open file" function to right-
  527.      Amiga O, select "KEY REBINDINGS/Rebind key", then select
  528.      "PROJECT/Open load file", then press and hold down the right
  529.      Amiga key, press and release the "O" key, and finally
  530.      release the right Amiga key.  From then on, instead of using
  531.      the menus for opening a file, you could just press right-
  532.      Amiga O.  To make this binding permanent, you should save
  533.      the current bindings, to a KEYTABLE.  Select "KEY BINDINGS/
  534.      Save", and type in the name of a file to save the key
  535.      bindings to.  If you want these bindings used every time you
  536.      use ReSource, you should save the key bindings as
  537.      "RS.keytable".
  538.      
  539.      With many programs, when you press and hold down the down
  540.      arrow key, to scroll down, a backlog of key repeats will
  541.      form, making it difficult to stop the scrolling, even after
  542.      releasing the offending key.  Where this would be problem,
  543.      the repeats are flushed, making control by keys better.
  544.      
  545.  
  546.  
  547.      LOADING:
  548.      
  549.      There are five functions that deal with loading, these are
  550.      "PROJECT/Open load file" and "PROJECT/Open binary file",
  551.      "PROJECT/Restore", "PROJECT/Dismble memory" and "PROJECT/
  552.      Read tracks".  The first of these will examine the start of
  553.      the file, to check if it is an Amiga load file.  Amiga load
  554.      files include all executable programs (excepting those using
  555.      overlays), libraries, device drivers, and fonts.  With this
  556.      type of load, ReSource examines, then strips out, all hunk,
  557.      relocation, and debug symbol information.  This information
  558.      is not lost, it is used internally to ReSource, to make
  559.      better decisions about data type setting, etc.
  560.      
  561.      To load a file, ReSource sometimes requires a great deal of
  562.      memory, especially when disassembling large files.  For any
  563.      file, the approximate memory requirements is 6 to 10 times
  564.      the size of the file.  As a further requirement, much of
  565.      this is required to be continuous.  ReSource is NOT
  566.      practical on a 512K machine.  If you have 2 Megs of fast
  567.      memory, you will be able to disassemble most programs.
  568.      
  569.      Any debug symbols will be shown as labels in their
  570.      respective places with the program, even the relocation
  571.      information is available.  For example, if you select
  572.      "DISPLAY/Hiliting/Reloc32", any relocated pointers are
  573.      hilited.  When disassembling, this information is quite
  574.      valuable, as it helps you to tell where code is, where
  575.      tables of pointers are, etc.  ReSource also makes heavy use
  576.      of this information in many functions, and is one of the
  577.      main reasons that it is so accurate in determining data
  578.      types, especially when telling code from ascii.  The hunk
  579.      information also tells you whether something was meant to
  580.      load to chip memory, which immediately lets you know that it
  581.      is probably graphics or sound data.
  582.      
  583.      If a program has the debug symbols left in it, it makes the
  584.      disassembling process much easier.  When the file is loaded,
  585.      for each debug symbol found, if it is nine characters long,
  586.      starts with "lb", followed by an upper case "A", "B", "C",
  587.      "L", or "W", at the point that the label is attached, the
  588.      data type will immediately be set to ascii, bytes, code,
  589.      longwords, or words, respectively.  Thus, if you have to
  590.      disassemble a program that you previously disassembled, then
  591.      reassembled, most of the data types will be set for you, as
  592.      the file is loaded.
  593.      
  594.      There is one other type of file that can be loaded in using
  595.      "PROJECT/Open load file", it is the ReSource data file, or
  596.      ".RS" file.  It is discussed in detail in another section.
  597.      
  598.  
  599.  
  600.      If ReSource cannot load the file as an Amiga load file, it
  601.      will automatically attempt to load it as-is, without looking
  602.      for hunk, relocation, and debug symbol information.  If it
  603.      is an Amiga load file, but has been corrupted, ReSource will
  604.      refuse to load it.  You can still load it, however, using
  605.      the "PROJECT/Load binary file" function.  With this
  606.      function, you can load any file, provided that there is
  607.      enough memory to load it.  This is handy for disassembling
  608.      operating systems, text files, or even normal Amiga load
  609.      files.  In this case, you may wish to examine the hunk
  610.      information inside an Amiga load file.
  611.      
  612.      The "PROJECT/Restore" function will attempt to load the same
  613.      file that you loaded last, this is useful when you "stuff
  614.      up", and just want to start again.  The restore function is
  615.      only usable when you loaded a file, NOT when you disassemble
  616.      memory directly, or read tracks from a floppy disk.
  617.      
  618.      When you open a file, and you are asked to select a file
  619.      using the file requester, you can cancel the load straight
  620.      away, and retain the current file.  If you hit the "okay"
  621.      gadget, and the file is not successfully loaded, (perhaps
  622.      because it is too large for available memory), you have lost
  623.      your current file.  If at this time, you select "cancel",
  624.      ReSource will give you the chance to quit, in case you
  625.      cannot or are unwilling to load any file.  If you don't
  626.      quit, ReSource will again offer the file requester, where
  627.      you may select a file to disassemble.
  628.      
  629.      ***********************************************************
  630.      
  631.      DATA FILES:
  632.      
  633.      The ReSource data file, or ".RS" file, is a file containing
  634.      most of the data areas internal to ReSource, while any
  635.      particular file is loaded.  This is used to save your work,
  636.      and later load it back into ReSource, so you can continue
  637.      disassembling a program some other time, without losing any
  638.      of what you have already done.  You could even send this
  639.      file to a friend, assuming that he/she has purchased
  640.      ReSource.  This should be particularly useful in
  641.      disassembling the Amiga operating system (Kickstart), as the
  642.      Kickstart .RS file does not contain any copyrighted
  643.      material, and so can be legally distributed.  Be aware that
  644.      you will require at least two megs of fast memory to load a
  645.      Kickstart .RS file.  Even the cursor position is saved in a
  646.      .RS file, making it easy for you to remember what you were
  647.      doing last when you saved the .RS file.  The .RS file is
  648.      only recognized with "PROJECT/Open load file", not the
  649.      "PROJECT/Open binary file".
  650.      
  651.      It is the content of the file that allows ReSource to
  652.      recognize a .RS file, not the name of the file.  However,
  653.      the file should have an extension of ".RS", so that it is
  654.      immediately recognized by humans as a ReSource data file.
  655.      
  656.      To save your work (doesn't matter how you loaded it), select
  657.      "PROJECT/Save .RS", and select a filename to save to.
  658.      
  659.  
  660.  
  661.      OUTPUT:
  662.      
  663.      Eventually, after disassembling a program, you will probably
  664.      want to save it to a text file, that you will later
  665.      assemble, perhaps after doing some modifications.  By using
  666.      the "OUTPUT/Save .asm" function, the entire file can be
  667.      saved as a text file, exactly as you see it on the screen. 
  668.      If you only wish to save part of the file, use "OUTPUT/Save
  669.      .asm/Partial".
  670.      
  671.      Another function dealing with output, is "OUTPUT/Save binary
  672.      image".  If you originally loaded a file as a binary image
  673.      file, using this function will save the file exactly as it
  674.      was loaded.  While this may at first seem to be useless,
  675.      consider that the cursor address in ReSource can be shown as
  676.      an absolute address, and that a program running in the
  677.      background (such as Metascope) could perform modifications
  678.      to the file, by overwriting the current information.  For
  679.      example, if you have a program that has some annoying
  680.      feature, you could quickly find the offending code with
  681.      ReSource, find out the absolute address of the cursor
  682.      (DISPLAY/Cursor address/Absolute), then simply overwrite the
  683.      offending code with "NOP" instructions.  Once this has been
  684.      done, select "OUTPUT/Save binary image", and you can use the
  685.      file immediately, without going through the complete
  686.      disassembly/re-assembly/link process.
  687.      
  688.      To find out how large the output .asm file will be, you can
  689.      select "OUTPUT/Calculate .asm size/ALL".  This will tell you
  690.      the output size, in bytes, K's, and as a percentage of a
  691.      floppy disk (which may be larger than 100%).  If you change
  692.      any of the options, it will most probably have some effect
  693.      on the size of the output file.  To make the output .asm
  694.      file smaller, most things in the "OPTIONS" menu should be
  695.      switched OFF, except for "DCB instructions", which if used,
  696.      can shrink the size of a .asm file considerably, especially
  697.      if there are large data areas.  Selecting OUTPUT/Tabs/Real
  698.      tabs will also make the output file size smaller, as will
  699.      DISPLAY/Blank lines/OFF.  If the size of the output file is
  700.      not a problem, then switch these options to suit your tastes.
  701.      
  702.      When you create a symbol, unless you have set OUTPUT/Symbol
  703.      table to "None", the symbol and its value will be stored, so
  704.      that a symbol table can be created at the beginning of the
  705.      output source code file.  This symbol table can take the
  706.      form of an equate table i.e.:
  707.      
  708.      AG_OpenLib      EQU     $00030000
  709.      AO_DOSLib       EQU     $00008007
  710.      AT_Recovery     EQU     $00000000
  711.      _LVOAlert       EQU     $FFFFFF94
  712.      _LVOClose       EQU     $FFFFFFDC
  713.      _LVOCreateProc  EQU     $FFFFFF76
  714.      _LVOCurrentDir  EQU     $FFFFFF82
  715.      
  716.  
  717.  
  718.      Alternatively, it can take the form of an "XREF" table i.e.:
  719.      
  720.              XREF    AG_OpenLib
  721.              XREF    AO_DOSLib
  722.              XREF    AT_Recovery
  723.              XREF    _LVOAlert
  724.              XREF    _LVOClose
  725.              XREF    _LVOCreateProc
  726.              XREF    _LVOCurrentDir
  727.      
  728.      While you are creating symbols, it matters only if you have
  729.      set the OUTPUT/Symbol table option to "None", whether it is
  730.      "EQU" or "XREF" at this time is not important.  The symbol
  731.      table is also stored in a .RS file.  When it is time to
  732.      create the .asm file, you can select either "EQU" or "XREF"
  733.      as the type of symbol table to create.  Even though you may
  734.      create many symbols with the same name, the symbol table
  735.      will contain only one entry for each symbol.  Thus, it will
  736.      correctly assemble with most assemblers.
  737.      
  738.      Either real tabs (ASCII value 9) or space may be used in the
  739.      output file.
  740.      
  741.      ***********************************************************
  742.      
  743.      DISPLAY:
  744.      
  745.      To cater for differing tastes, how ReSource goes about
  746.      displaying information can be varied dramatically.  Overlong
  747.      lines may or may not wrap around, code may be shown in upper
  748.      case, or lower case.  Data declarations can be shown in
  749.      upper case or lower case.  You can have blank lines appear
  750.      after conditional branches, after all branches, or none at
  751.      all.  Any number can be shown in hexadecimal, decimal,
  752.      binary, or ASCII, if within the required range.  Numbers
  753.      below 10 in value can be globally converted to decimal,
  754.      numbers below 16 can be globally converted to decimal, or
  755.      none.  Each line that doesn't start with a label can instead
  756.      show the current offset.  Section statements, the END
  757.      statement, labels, hidden labels, symbols, and two types of
  758.      comments can be individually be set ON or OFF at any time. 
  759.      The settings of these options can be made permanent by
  760.      selecting the required functions in Macro #19 (the last
  761.      local macro), and saving the macro table as "S:RS.macros". 
  762.      See the section on macros for more information.  Selecting
  763.      the function "OPTIONS 1/Labels/OFF" does NOT remove any
  764.      labels, it simply stops them from being shown, until you
  765.      select "OPTIONS 1/Labels/ON" again.  For example, you might
  766.      wish to search for "lbC" as a string inside a comment,
  767.      unless you turn labels off, you will have to spend a long
  768.      time searching for the real target, as many labels will
  769.      start with "lbC".
  770.      
  771.  
  772.  
  773.      SEARCH:
  774.      
  775.      ReSource has some very powerful search functions.  You can
  776.      select from a normal search, or a pattern search.  You can
  777.      search forwards, backwards, or a special combined search,
  778.      that searches in both directions at the same time, which
  779.      will find the "nearest" occurrence of the search string. 
  780.      For use in macros, you can also search just the current
  781.      line, or the accumulator.
  782.      
  783.      The text that you see on the display will be the text that
  784.      will be searched through.  For the purpose of searches, tabs
  785.      are set to real tabs, not spaces.  Thus, if you wish to
  786.      search for:
  787.      
  788.              MOVE.L  #100,D0
  789.      
  790.      , you would press "tab" where you see spaces in the above
  791.      line.  When using the pattern search, the wildcards are
  792.      those used in all ARP programs.  For completeness, they are
  793.      repeated here:
  794.      
  795.      ***********************************************************
  796.                         ARP and Wildcards
  797.      
  798.      ARP has an extensive set of wildcards, and most ARP programs
  799.      allow them to be used.  ARP supports ALL of the AmigaDOS set
  800.      of wildcards, as well as the more standard Unix* style of
  801.      wildcards.  ARP supports the following wildcard characters,
  802.      note that these are valid inside or out of quotes:
  803.      
  804.      
  805.           (a|b|c)   Will match one of a, b or c.
  806.                     These can be patterns.
  807.      
  808.           ? Matches any single character
  809.           #<pat>   Pattern repeated 0 or more times,
  810.                    in particular, #? matches anything.
  811.      
  812.           [char]   A set of characters, for example,
  813.                    [abc] or [a..c] specify the same set.
  814.      
  815.           [^char]   Match everything but this set of characters.
  816.      
  817.           *         0 or more occurrences of any character.
  818.      
  819.      
  820.      These can be used in combination, of course, so that *.(c|h)
  821.      or *.[ch] will match any filenames ending in either .c or .h
  822.      proceeded by any number of characters, including no
  823.      characters.
  824.      
  825.  
  826.  
  827.      For example, if you want to search for "JSR" or "BSR", you
  828.      would specify "?SR" as the search pattern, and you would use
  829.      the pattern search, not the normal search.  Here's some more
  830.      examples:
  831.      
  832.      lb[ABCWL] . .......would find any occurrence of "lbA",
  833.      "lbB", "lbC", "lbW", or "lbL".  "lbM" would NOT constitute a
  834.      valid match.
  835.      
  836.      J(MP|SR) -$????*(A6*) . .......would get a match on the
  837.      following lines:
  838.      
  839.       JMP -$00C6(A6)
  840.       JSR -$00C6(A6)
  841.       JSR -$01FE(A6)
  842.       JMP -$FFFF(A6)
  843.      
  844.      but not on the following lines:
  845.      
  846.       JMP $00C6(A6)
  847.       JSR -$00C6(A5)
  848.       JSR $1FE(A6)
  849.       JMP (A6)
  850.      
  851.      Note that a real tab character was used above, between
  852.      "J(MP|SR)" and "-$????\(A6\)".  During a search, whether
  853.      tabs are set to real tabs, or spaces, is not important.
  854.      
  855.      ***********************************************************
  856.      COMMAND LINE PARAMETERS:
  857.      -----------------------
  858.      
  859.      When you run ReSource from a CLI, you can supply a
  860.      parameter, so that ReSource can gets its input straight
  861.      away.  Examine the following examples:
  862.      
  863.      ReSource c:popcli
  864.      (The program "popcli" will be loaded as a load file, from
  865.      the C: device)
  866.      
  867.      ReSource libs:arp.library
  868.      (The file "arp.library" will be loaded from the libs:
  869.      device, as a load file)
  870.      
  871.      ReSource *b c:popcli
  872.      (The file "popcli" will be loaded as a binary image, from
  873.      the C: device)
  874.      
  875.  
  876.  
  877.      ReSource *
  878.      (Kickstart as it appears in memory is loaded)
  879.      
  880.      ReSource *m $FC0000 $FD0000
  881.      (The first 64K of Kickstart will be loaded)
  882.      
  883.      ReSource *DF0: 0 0 1
  884.      (The boot sector from DF0: will be loaded, a total of 512
  885.      bytes.  Use this to check for/disassemble viruses)
  886.      
  887.      ReSource *DF1: 40 41
  888.      (The entire directory cylinder from DF1: will be loaded, 11K
  889.      in all)
  890.      
  891.      ReSource *m $400 $800
  892.      (For most Amigas, this will load the exec library)
  893.      
  894.      ReSource *m 0 1
  895.      (Load one byte of memory, at location zero)
  896.      
  897.      ***********************************************************
  898.      Amiga, AmigaDOS, and Kickstart are registered trademarks of
  899.      Commodore-Amiga, Inc.
  900.      ***********************************************************
  901.