                    15th November, 1994

A 6502 assembler, as6502-1.60

     Using the 6800 assembler source code of ASxxxx version 1.50 by
     Alan R. Baldwin, I have written a couple of files to make the
     assembler support 65C02. For those who are familiar with NMOS
     6502s, i.e. the processors in the Commodore microcomputers, for
     instance, there are a couple of new instructions that work only
     in the CMOS 6502 family. I have used the Rockwell document
     29651N52, a data booklet of R65C02, R65C102 and R65C112 as a
     source of opcode information.

     The original work of Alan Baldwin is on the SIMTEL20 archive,
     simtel20.wsmr.army.mil.  Or at least it was there, I don't know
     if the archive exists any more.  But fortunately, ftp.funet.fi has
     a mirror of some SIMTEL files, and this particular file is in
     /pub/msdos/SimTel/crossasm/cug292wk.zip.  It contains
     crossassemblers for many platforms, like the Motorola 68xx
     processors, and the Zilog Z80.

     You can find the complete ASxxxx package on the anonymous FTP server
     shop-pdp.kent.edu. The files are in the subdirectories of the
     directory du3:/cug292. (The subdirectories have the extension dsk.)

Directory listing

     As I merely have exploited Alan R. Baldwin's work, not all files
     in this directory are written by me. A complete commented
     directory listing of this archive file follows:

     Documentation
        README          This file
      * asmlnk.doc      Instructions for the ASxxxx cross assemblers
        r65c02.asm      Rockwell 65C02 instruction set, written in a
                        format accepted by the assembler

     Files common for all ASxxxx assemblers
      + asm.h           Header file for the ASxxxx cross assemblers
      + asmain.c        Main module of the cross assemblers
                        A bug in parsing the command line is fixed by me
      * alloc.h         Definitions for memory allocation functions
                        referenced to by both ASxxxx and ASLINK
                        You may have to copy this to your INCLUDE subdirectory
                        in order to ensure that the compiler finds this.
      * aslex.c
      + assym.c
      * assubr.c                Miscellanous ASxxxx modules
      * asdata.c
      * aslist.c
      * asout.c
      * asexpr.c        The module that parses most of the statements
      + asexpr1.c       Improved version of ASEXPR.C (see below)
                        Replace the old ASEXPR.C with this
                        if you want to use this.

     6502 specific ASxxxx files
        r6502.h         Header file for the R65C02 specific C files
        r52ext.c        Contains some information of this R65C02 part
        r52pst.c        Contains the R65C02 op-codes
        r52adr.c        Determines addressing modes of instruction parameters
        r52mch.c        Processes an instruction

     ASLINK files
      * aslink.h        Header file for the ASLINK linker utility
      + lkmain.c
      * lkhead.c
      * lkarea.c
      * lkdata.c
      * lkeval.c
      * lklex.c                 Miscellanous ASLINK modules
      * lksym.c
      * lkrloc.c
      * lklist.c
      * lkihx.c
      * lks19.c
        lkcbm.c         The module that produces CBM-style program files.


        Note:   The files marked with `*' are written by Alan R. Baldwin.
                The files marked with `+' are cosmetically changed by me.
                Unmarked files are heavily changed or created by me.


Some changes to the original files

  asm.h
     I changed the definitions of DOT_S and DOT, so that the assembler
     uses the asterisk character (*) instead of a dot (.) for the
     current location.

  asmain.c
     I did not correct the handling of MS-DOS style file names. If you specify
     a directory path preceding the file name, correct behaviour of the program
     would be that the resulting files would be created in the default
     directory instead of the directory that contain the respective source
     file. A real bug occurs when the path specification contains dots.

  asexpr.c
     I found the radix specification system difficult.  You couldn't
     write hexadecimal numbers comfortably, even if you had ordered
     .radix x.  The figures were not allowed start with a letter, in
     which case you had to add an extra 0 before them. But the
     combination 0d specifies decimal numbers and 0b binary numbers,
     so if the hexadecimal number starts with those, you have to write
     0xb... or 0xd...

     That's why I patched asexpr.c so that it allows the $, $%, $& and
     $# prefixes.  The $ prefix is for the hexadecimal numbers, and the
     three others are for binary, octal and decimal, respectively.
     Examples of valid numbers are $FCE2, $%1001011, $&377 and
     $#65535, and of course 1001011, 377 and 65535, if the respective .radix
     directive is used.  But hexadecimal figures may still not start
     with a letter, they must start with a number or $.

  asm.h
  aslink.h
     You may find the original FILSPC specification too small.

Usage
  The assembler and the linker support several source files.  So, after
  you have written the assembly sources, you have to compile each file
  using "as6502 -o file.asm".  Then, make a control file for the linker,
  with the file suffix .lnk.  The file should contain the string "-r"
  on its first line, specifying Commodore program file output, and the
  modules listed on the following lines.  Run the command
  "aslink -f file.lnk" to compile the program.

Summary

     If you notice any strange behaviour of as6502, feel free to send me
     E-mail and describe the problem, and I'll try to help you.

     Marko Mkel
     Marko.Makela@HUT.FI
