full directives of no$nes build in 65XX style assembler ?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

Post Reply
User avatar
yefeng
Posts: 6
Joined: Thu Mar 12, 2009 4:09 am
Location: China

full directives of no$nes build in 65XX style assembler ?

Post by yefeng »

Hello, I am puzzled when I use the no$nes build in assembler named A22i.
from author's website, i can find a sample code for this, but, it's 80xx style, not
native .65xx style, is there anyone have the full directives of the A22i assembler
for .65xx style?
below is a part of document in the emulator/debugger:

CPU Assembler Directives/Syntax

Code: Select all

Below are some common 65XX assembler directives, and the corresponding expressions in 80XX-style language.


  65XX-style    80XX-style         Expl.
  .native       .nocash            select native or nocash syntax
  *=$c100       org 0c100h         sets the assumed origin in memory
  *=*+8         org $+8            increments origin, does NOT produce data
  label         label:             sets a label equal to the current address
  label=$dc00   label equ 0dc00h   assigns a value or address to label
  .by $00       db 00h             defines a (list of) byte(s) in memory

  .byt $00      defb 00h           same as .by and db
  .wd $0000     dw 0000h           defines a (list of) word(s) in memory
  .end          end                indicates end of source code file
  |nn           [|nn]              force 16bit "00NN" instead 8bit "NN"
  #<nnnn        nnnn AND 0FFh      isolate lower 8bits of 16bit value
  #>nnnn        nnnn DIV 100h      isolate upper 8bits of 16bit value
  N/A (?)       fast label         ensure relative jump without page crossing

  N/A (?)       slow label         ensure relative jump with page crossing

Special Directives

  .65xx       Select 6502 Instruction Set
  .nes        Create NES ROM-Image with .NES extension
  .c64_prg    Create C64 file with .PRG extension/stub/fixed entry
  .c64_p00    Create C64 file with .P00 extension/stub/fixed entry/header
  .vic20_prg  Create VIC20/C64 file with .PRG extension/stub/relocated entry
  end entry   End of Source, the parameter specifies the entrypoint

The C64 files contain Basic Stub "10 SYS<entry>" with default ORG 80Eh.

VIC20 Stub
The VIC20 Stub is "10 SYSPEEK(44)*256+<entry>" with default ORG 1218h, this relocates the entryoint relative to the LOAD address (for C64: 818h, for VIC20: 1018h (Unexpanded), 0418h (3K Expanded), 1218h (8K and more Expansion). It does NOT relocate absolute addresses in the program, if the program wishes to run at a specific memory location, then it must de-relocate itself from the LOAD address to the desired address.
User avatar
yefeng
Posts: 6
Joined: Thu Mar 12, 2009 4:09 am
Location: China

Re: full directives of no$nes build in 65XX style assembler

Post by yefeng »

test.asm file:

Code: Select all


    .65xx       ; Select 6502 Instruction Set
    .native     ; select native syntax

    *=$c000
reset:
    sei
    cld
    ldx #$00
    stx $2000
    stx $2001
    dex
    txs
vw1:
    lda $2002
    bpl vw1
vw2:
    lda $2002
    bpl vw2
    
    ;some other initial code here...
    
    lda #$80	;enable nmi interrupt
    sta $2000
    lda #$1E	;display on
    sta $2001

;main loop
main:
    jmp main
    
nmi:
irq:
    rti
main_code_end:

    *=$fffa
    .wd nmi
    .wd reset
    .wd irq
    
    .end

test.SYM file:

Code: Select all

;no$nes symbolic information file
;generated by a22i

00:C000 reset
00:C00C vw1
00:C011 vw2
00:C020 main
00:C023 nmi
00:C023 irq
00:C024 main_code_end
00:FFFA .wrd:0006
the binary file test.bin as below:

Code: Select all

Offset      0  1  2  3  4  5  6  7   8  9  A  B  C  D  E  F
00000000   78 D8 A2 00 8E 00 20 8E  01 20 CA 9A AD 02 20 10   x丌.? ? 蕷? .
00000010   FB AD 02 20 10 FB A9 80  8D 00 20 A9 1E 8D 01 20   . .€? ?? 
00000020   4C 20 C0 40 23 C0 00 C0  23 C0                     L 繞#??
The problem is how to fill blank bytes to the range: $C024 - $FFF9
From nocash's sample code MAGIC FLOOR,
I know the directive "deff" can be used under the 80xx style syntax.

Code: Select all

; 80xx style
;---
deff 0fffah-$   ;blank-fill space up to reset vector
dw nmi_handler  ;NMI vector   [FFFAh]
dw start        ;reset vector [FFFCh]
dw 0ffffh       ;break vector [FFFEh]
end
Which directive to use with the .65xx style syntax ?
Post Reply