home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / emulaton / asm6503 / !help next >
Text File  |  1998-08-27  |  9KB  |  179 lines

  1. ---------------------------------\---------------------\---\-\   Alain BROBECKER
  2.    asm6502     v0.06 (26aug1998)  >  © Alain BROBECKER  >   > >  rte de Dardagny
  3. ---------------------------------/---------------------/---/-/    01630 CHALLEX
  4.                                                                       FRANCE
  5.                                                             abrobecker@yahoo.com
  6.                                             http://www.cybercable.tm.fr/~brooby/
  7.  
  8.  
  9.                Contents ---->-->->> 1. Legalities
  10.                                     2. What? Why?
  11.                                     3. asm6502 usage
  12.                                     4. No Future
  13.                                     5. History
  14.  
  15.  
  16.  
  17. ------------------------------->  1. Legalities  <------------------------------
  18.  
  19.   * YOU CAN FREELY COPY THIS SOFTWARE AS LONG AS YOU LEAVE FILES UNALTERED,
  20.     AND DON'T USE IT FOR COMMERCIAL PROFIT (PDL SHALL CONTACT ME FIRST).
  21.   * PLEASE NOTE THAT YOU USE IT (or not =) AT YOUR OWN RISKS! (maybe i shall
  22.     mention i do use it at my own risks =)
  23.   * COMMENTED SOURCECODE IS PROVIDED FOR INSPIRATION TO ALL CODERS OUT THERE.
  24.     USAGE OF PARTS OF CODE OR IDEAS IS ENCOURAGED AS LONG AS YOU CREDIT ME AND
  25.     YOUR PRODUCT IS FREEWARE.
  26.  
  27.  
  28.  
  29. ------------------------------>  2. What? Why?  <-------------------------------
  30.  
  31.   asm6502 is a 6502 cross assembler, ie a program which will convert a source
  32. written for the WDC 6502 processor into the 6502 binary code. What is the use
  33. of such a program on ARM based computers will you ask? There are two possible
  34. answers...
  35.  
  36.   The first is one game programmers encounter a lot: some platforms, like
  37. consoles or computers under development, don't have the software (text editor,
  38. programming languages) and/or hardware (keyboard) to allow easy programming.
  39. The usefulness of cross-programming is then obvious. As an example, Atari's
  40. 'Lynx' console is based upon a 6502 (well a 65sc02 in fact) processor. Also,
  41. programming for the Commodore 64 (demos or whatever) would be much easier with
  42. Zap+asm6502 than with a c64 assembler.
  43.  
  44.   The second answer comes from a recent fashion... Emulators. Another of their
  45. possible name would be cross-computers, so cross-programming is dedicated to
  46. your machine again, and cross-programming becomes as useful as programming,
  47. ie a total waste of time. Since I'm delighted at doing such unuseful things,
  48. I programmed asm6502. I hope a side effect of cross-programming will be to
  49. have my knowledge in computers increasing.
  50.  
  51.   Needless to say, I had a c64 when I was young, but used it for gaming only.
  52. One year ago I collected an old c64 (people now throw them away! =) and
  53. decided to program on it. I was impressed by the profimat assembler (macros,
  54. 8Kb size, speed), but the c64's basic editor was so lame that I abandonned all
  55. hopes. The only solution was cross-programming. I went through good emulators
  56. and cross-assemblers on the PC, but I did want the same on my Archimedes.
  57. Skoe/Expression already made a cross assembler, but it worked neither on
  58. Arm2+RiscOS2, neither on StrongArm+RiscOS3.7. So it was clear in my mind, I had
  59. to make my own 6502 assembler, and here it is.
  60.  
  61.   Last, i will mention two c64 emulators: Frodo v4.1 by Christian BAUER which
  62. has been adapted to many platforms (Unix, BeOS, Amiga, RiscOS, Win95...), is
  63. freeware, really slow (StrongARM recommended) and has very precise emulation.
  64. The other one, BreadBox64 by Coyer/Daydream Software, is (now) shareware, fast
  65. but less accurate.
  66.  
  67.   --> NEW! <-- My 6502 emulator is now finished, and i have started to work
  68. on an Acorn ATOM emulator: ATOMbomb. Sure you are impatient to see it
  69. launched... =)
  70.  
  71.  
  72.  
  73. ----------------------------->  3. asm6502 usage  <-----------------------------
  74.  
  75.   Execute asm6502 from the CLI by typing 'asm6502 SourceName'. The name of
  76. the binary object to produce shall be given in the source with the #name
  77. pseudo-operation.
  78.  
  79.             List of pseudo-operations:
  80.             --------------------------
  81. #list                               ; If you want the assembly listing.
  82. #name       filename                ; Gives the name to save to.
  83. #type       filetype                ; Gives the filetype of dest file.
  84. #base       imm16                   ; Defines the base adress for assembly,
  85.                                     ;   shall be used once only in a file.
  86. #set        variable = value        ; Both format are available, but in 1st one
  87. #set        variable value          ;   you must have spaces around the =.
  88. #incbin     filename                ; Will include the binary file there.
  89. #b          imm8, ... ,imm8         ; Byte.
  90. #w          imm16, ... ,imm16       ; Word (high byte first).
  91. #rw         imm16, ... ,imm16       ; Reversed word (low byte first).
  92. #align      mask16,byte             ; Copy byte until adress AND mask16=0.
  93. #dsb        nb,byte                 ; Copy byte nb times.
  94. #rept       N                       ; This couple of pseudo-op delimits a zone
  95. #endr                               ;   which will be repeated N times. Very
  96.                                     ;   usefull, but cannot be nested!
  97.  
  98.             General remarks
  99.             ---------------
  100. * The 6502 mnemonics are the standard ones, but they must be in lowercase only.
  101.   Ooooops, not exactly true, for a zero page access, you must write z,???.
  102. * There are two instruction separators, which are Line Feed (LF=&0a) and ":".
  103.   But if you put ":" in a comment it will be ignored, while LF won't.
  104. * The function evaluator uses the BASIC one, so the conventions are similar.
  105.   (pfiuuu... This saved me a great lot of coding) So you must use & instead of
  106.   the c64's standard $ for hexadecimal values.
  107.   As in basic, "aANDb" doesn' t work! Use "a AND b" instead. (Or "a ANDb")
  108. * The "bcc" and "bcs" instructions can be assembled as "blt" (branch less than)
  109.   and "bge" (branch greater or equal), respectively.
  110. * Avoid variable names ending with % and $, since I use some of them.
  111. * Both "asl" and "asl a" are valid for accumulator adressing mode, and the
  112.   same comment apply for lsr, rol, ror.
  113. * You can't have a variable called "a" since this stands for the accu.
  114. * Some assembler uses "<" or ">" to get low or high byte of an expression.
  115.   With asm6502 replace them with "255ANDexpr" or "expr>>8".
  116. * You can give the displacement for the branchs instead of an adress by
  117.   writing "b?? -imm8" or "b?? +imm8".
  118.   For example:          ldy #0
  119.                       .vsync
  120.                         cpy &d012
  121.                         bne -3      ; is equivalent to bne vsync.
  122. * There are two kinds of error reports... When an error has been detected by
  123.   asm6502 it looks like "***error at line 1: &100 is not a byte" and the
  124.   assembly will continue anyway (total number of errors given at the end).
  125.   Second case is when an error has been detected by the BASIC, like in
  126.   "Unknown or missing variable at line 1  (asm6502 line 2370)", then assembly
  127.   is stopped, the first number indicates where you should look at in your 6502
  128.   code while the second one tells where the asm6502 program was when the error
  129.   occured (this is usefull for debugging asm6502 =).
  130.  
  131.  
  132.  
  133. ------------------------------->  4. No Future  <-------------------------------
  134.  
  135. Here are some features I would like to add... (Those are no promises! =)
  136. * Macros. (Maybe not that tough)
  137. * Own function evaluator (theory is ready, but code isn't), because BASIC's
  138.   one (is convenient but) doesn't suit this usage: it won't detect some errors
  139.   such as label redefinition.
  140. * Local labels. (Needs own function evaluator?)
  141. * #ascii pseudo-op. (or #b "...."?)
  142. * #include pseudo-op. (Replace main loop by a procedure?)
  143. * Uppercase possibility. (By converting everything to lowercase beforehand?
  144.   Having opcodes in lower+upper cases?)
  145. * Hash code table instead of dichotomy.
  146. * Rewriting in assembly (efficiency) or C (portability).
  147.  
  148.  
  149.  
  150. -------------------------------->  5. History  <--------------------------------
  151.  
  152. 26aug1998 v0.06  -- Removed bug in #rept.
  153.                  -- Now a ":" in a comment is ignored.
  154.                  -- Changed display of BASIC's error report.
  155.                  -- Now displays #dsb,#align as memory dump (as for #incbin).
  156.                  -- Changed c64 examples to have them filetyped to &064.
  157.                  -- Old emul6502 programs replaced by more interesting ones.
  158.  
  159. 03aug1998 v0.05  -- Corrected memory dump display of "#incbin" listing.
  160.  
  161. 31may1998 v0.04  -- Since I have begun the 6502 emulator, I have used asm6502
  162.                     a lot to produce small test progs. Bugs seem to despise
  163.                     this program, so here it is at l(e)ast... =)
  164.  
  165. 01mar1998 v0.04ß -- Cleaned the code, added #type pseudo-op and allowed space
  166.                     as a separator just after a label.
  167.  
  168. 09sep1997 v0.03ß -- Added "b?? +imm8" & "b?? -imm8" assembly, improved the
  169.                     FNsize function and modified operand identification.
  170.  
  171. 08sep1997 v0.02ß -- Added dichotomy for mnemonic identification and changed
  172.                     string accesses, resulting in 25% speed increase.
  173.  
  174. 07sep1997 v0.01ß -- First (seemingly) working version. Let's face it, I'm
  175.                     happy, but I will have to perform intensive testing
  176.                     before I unleash the beast.
  177.  
  178. 18may1997 v0.00ß -- 'asm6502' project started (and soon halted =).
  179.