This is my Nintendo (8 bit beast) assembler. This assembler was originally
written by J. H. Van Ornum, and is based on the changes made by David Michel.
This document is also based on David Michel's document.

    Usage
    -----

        Options available in the assembler:

        -a Displays resulting assembly code.
        -h Prevents adding INES header to file..
        -m Expands macros in listing.
        -? Get Help

    Source Code
    -----------
        I've included two demos with source that I found on the internet.
        The first is the 'NES Colour Bars Program' by Mark Knibbs.
        The original can bee found at
        http://www.netcomuk.co.uk/~markk/index.html.

        The second one is 'JunkDemo' by 'TYoung79@aol.com'. The orginal can
        be found at
        http://members.aol.com/TYoung79/nesprog.html.

    Instructions set
    ----------------

        +------+----------+-----------------------------+
        |      | NVTBDIZC | Description                 |
        +------+----------+-----------------------------+
        | ADC  | XX0---XX | Add with Carry              |
        | AND  | X-0---X- | Logical AND                 |
        | ASL  | X-0---XX | Arithmetic Shift left       |
        | BCC  | --0----- | Branch if Carry Clear       |
        | BCS  | --0----- | Branch if Carry Set         |
        | BEQ  | --0----- | Branch if Equal             |
        | BIT  | XX0---X- | Bit Test                    |
        | BMI  | --0----- | Branch if Minus             |
        | BNE  | --0----- | Branch if Not Equal         |
        | BPL  | --0----- | Branch if Plus              |
        | BRA  | --0----- | Branch Always               |
        | BRK  | --0----- | Break                       |
        | BVC  | --0----- | Branch if Overflow Clear    |
        | BVS  | --0----- | Branch if Overflow Set      |
        | CLC  | --0----0 | Clear Carry flag            |
        | CLD  | --0-0--- | Clear Decimal flag          |
        | CLI  | --0--0-- | Clear Interrupt disable     |
        | CLV  | -00----- | Clear Overflow flag         |
        | CMP  | X-0---XX | Compare A with source       |
        | CPX  | X-0---XX | Compare X with source       |
        | CPY  | X-0---XX | Compare Y with source       |
        | DEC  | X-0---X- | Decrement                   |
        | DEX  | X-0---X- | Decrement X                 |
        | DEY  | X-0---X- | Decrement Y                 |
        | EOR  | X-0---X- | Logical Exclusive OR        |
        | INC  | X-0---X- | Increment                   |
        | INX  | X-0---X- | Increment X                 |
        | INY  | X-0---X- | Increment Y                 |
        | JMP  | --0----- | Jump                        |
        | JSR  | --0----- | Jump to Sub Routine         |
        | LDA  | X-0---X- | Load A                      |
        | LDX  | X-0---X- | Load X                      |
        | LDY  | X-0---X- | Load Y                      |
        | LSR  | 0-0---XX | Logical Shift Right         |
        | NOP  | --0----- | No Operation                |
        | ORA  | X-0---X- | Logical inclusive OR        |
        | PHA  | --0----- | Push A                      |
        | PHP  | --0----- | Push P                      |
        | PLA  | X-0---X- | Pull A                      |
        | PLP  | XXXXXXXX | Pull P                      |
        | ROL  | X-0---XX | Rotate Left                 |
        | ROR  | X-0---XX | Rotate Right                |
        | RTI  | XXXXXXXX | Return from Interrupt       |
        | RTS  | --0----- | Return from Sub Routine     |
        | SBC  | XX0---XX | Substract with Carry        |
        | SEC  | --0----1 | Set Carry flag              |
        | SED  | --0-1--- | Set Decimal flag            |
        | SEI  | --0--1-- | Set Interrupt disable       |
        | STA  | --0----- | Store A                     |
        | STX  | --0----- | Store X                     |
        | STY  | --0----- | Store Y                     |
        | TAX  | X-0---X- | Transfer A to X             |
        | TAY  | X-0---X- | Transfer A to Y             |
        | TSX  | X-0---X- | Transfer S to X             |
        | TXA  | X-0---X- | Transfer X to A             |
        | TXS  | --0----- | Transfer X to S             |
        | TYA  | X-0---X- | Transfer Y to A             |
        +------+----------+-----------------------------+


    Operand syntax
    --------------

        A        accumulator
        #i       immediate
        #i,<n    immediate and zero page              | 
        #i,n     immediate and absolute               | 
        #i,n,X   immediate and absolute indexed by X  |
        <n       zero page
        <n,X     zero page indexed by X
        <n,Y     zero page indexed by Y
        [n]      indirect (*)
        [n,X]    indirect pre-indexed by X (*)
        [n],Y    indirect zero page post-indexed by Y
        r        relative                             | BRA/Bcc
        n        absolute
        n,X      absolute indexed by X
        n,Y      absolute indexed by Y

        (*) can be zero page or absolute


    Symbols
    -------

        Two types of symbol are supported, global symbols and local
        symbols. Local symbols are preceded by a dot '.' and are 
        valid only between two global symbols. A symbol can be 
        followed by a colon ':' but this is not necessary.


    Expressions
    -----------

        The assembler supports very complex expressions. You can
        use as many level of parenthesis as you want and spaces
        between operators and numbers are possible. For the
	priority, the same rules as C apply.

        Numbers can be written in four base : hexa ($), octal (&),
        binary (%) and decimal. Character values are also supported
        (ie. 'A') and all the usual operators are present :
        +, -, *, /, %, ^, &, |, ~, <<, >>.

        In an expression four predefined functions can be used too :

            HIGH(), return the high byte of a number.

            LOW(),  return the low byte.

            BANK(), return the bank index of a symbol. If no
                    symbol, or more than one, are given, the
                    function return an error.

            PAGE(), return the page index of a symbol.
                    See BANK for errors.


    Macros
    ------

        Up to nine parameters, \1 to \9, can be used in a macro call.
        There's also a special parameter \@ that returns a different
        number for each macro; it is used to make local symbols inside
        a macro :

            abs     macro
                     lda   \1
                     bpl   .x\@
                     eor   #$FF
                     inc   A
                     sta   \1
            .x\@:
                    endm


    Directives
    ----------


        LIST,    tell the assembler that you want a complete listing
                 file. You can later stop temporarily the output with
                 the NOLIST directive and restart it with LIST.

        NOLIST,  stop the listing output.

        MLIST,   include the macros in the listing file.

        NOMLIST, stop expanding macros in the listing file.

        EQU,     assign a value to a symbol. The character '=' has
                 the same function too.

        BANK,    select a ROM bank (0-127) and reset the location
                 counter to the latest known position in this bank.

        ORG,     set the location of the program counter. The thirteen
                 lower bits of the address inform the assembler about
                 the offset in the ROM bank and the third upper bits
                 represent the page index.

        DB,      data byte(s).

        DW,      data word(s).

        RSSET,   set the internal counter of the RS directive to 
                 a specified value.

        RS,      assign a value to a symbol; a bit like EQU but here
                 the value assigned is taken from an internal counter
                 and after the assignation this counter is increased
                 by the value specified in the RS directive.
                 It's a very handy way of defining variables, here's
                 a small example:

                             .rsset $2000 ; set the initial value of
                                          ; the RS internal counter
                     my_byte .rs 1        ; define a var of 1 byte
                     my_word .rs 2        ;        "        2 bytes

        MACRO,   start a macro definition.

        ENDM,    end a macro definition.

        INCBIN,  include a binary file at the current location. If
                 the file is bigger than a ROM bank, as many successive
                 banks as necessary will be filled and the bank and
                 the location counter will be updated.

        INCLUDE, include a source file at the current location.
                 Up to 7 levels are possible.

        INESPRG, specifies the number of 16k prg banks.

        INESCHR, specifies the number of 8k chr banks.

        INESMAP, specifies the mapper used.

        INESMIR, specifies VRAM mirroring of the banks. refer to INES
        header documents (neshdr20.txt). This file should be part of
        the compiler archive.

    NES IRQ vectors
    -------------------

        $FFFA   NMI
        $FFFC   RESET
        $FFFE   IRQ


    History
    -------

        v0.1 : May 4th, 1998
               - removed all the HuC6820 opcodes from David Michel's version.
               - added directives to support the INES file format.
                 (inesprg, ineschr, inesmap, inesmir)

    Thanks to
    ---------

        - J. H. Van Ornum, for his old 6502 assembler (11/May/84).
            I used his sources as a base for the assembler.

        - David Michel, for his version of the compiler. The primary contribution
            is the banking stuff.


 ------------
 David Michel <dmichel@easynet.fr>
 modified by Charles Doty (cdoty@doitnow.com)


