Portable 65xx Assembler [16.06] ;=============================================================================== ; ; A Simple W65C816 Program ;------------------------------------------------------------------------------- ; Copyright (C),2016 HandCoded Software Ltd. ; All rights reserved. ; ; This work is made available under the terms of the Creative Commons ; Attribution-NonCommercial 2.0 license. Open the following URL to see the ; details. ; ; http://creativecommons.org/licenses/by-nc/2.0/ ;------------------------------------------------------------------------------- ; ; Notes: ; ; ; ;------------------------------------------------------------------------------- .include "../w65c816.inc" ;=============================================================================== ; __ ____ ____ ____ ___ _ __ ; \ \ / / /_| ___| / ___( _ )/ |/ /_ ; \ \ /\ / / '_ \___ \| | / _ \| | '_ \ ; \ V V /| (_) |__) | |__| (_) | | (_) | ; \_/\_/ \___/____/ \____\___/|_|\___/ ; ; Western Design Center W65C816 device definitions ;------------------------------------------------------------------------------- ; Copyright (C)2015 HandCoded Software Ltd. ; All rights reserved. ; ; This work is made available under the terms of the Creative Commons ; Attribution-NonCommercial-ShareAlike 4.0 International license. Open the ; following URL to see the details. ; ; http://creativecommons.org/licenses/by-nc-sa/4.0/ ; ;=============================================================================== ; Notes: ; ; Various macros and definitions for the W65C816 microcontroller. ; ;=============================================================================== ; Revision History: ; ; 2015-12-18 AJ Initial version ;------------------------------------------------------------------------------- ; $Id$ ;------------------------------------------------------------------------------- .65816 Portable 65xx Assembler [16.06] ;=============================================================================== ; Status Register Bits ;------------------------------------------------------------------------------- 00000080 = N_FLAG .equ 1<<7 00000040 = V_FLAG .equ 1<<6 00000020 = M_FLAG .equ 1<<5 00000010 = X_FLAG .equ 1<<4 00000010 = B_FLAG .equ 1<<4 00000008 = D_FLAG .equ 1<<3 00000004 = I_FLAG .equ 1<<2 00000002 = Z_FLAG .equ 1<<1 00000001 = C_FLAG .equ 1<<0 ;============================================================================== ; Macros ;------------------------------------------------------------------------------ ; Puts the processor in emulation mode. A, X and Y become 8-bits and the stack ; is fixed at $0100-$01ff. emulate .macro sec xce .endm ; Puts the processor in native mode. The size of the memory and index register ; operations is not controlled by the M & X bits in the status register. native .macro clc xce .endm ; Resets the M bit making the accumator and memory accesses 16-bits wide. long_a .macro rep #M_FLAG .longa on .endm ; Resets the X bit making the index registers 16-bits wide long_i .macro rep #X_FLAG .longi on .endm ; Resets the M and X bits making the accumator, memory accesses and index ; registers 16-bits wide. long_ai .macro rep #M_FLAG|X_FLAG .longa on Portable 65xx Assembler [16.06] .longi on .endm ; Sets the M bit making the accumator and memory accesses 16-bits wide. short_a .macro sep #M_FLAG .longa off .endm short_i .macro sep #X_FLAG .longi off .endm short_ai .macro sep #M_FLAG|X_FLAG .longa off .longi off .endm .page0 ;=============================================================================== ; Memory Areas ;------------------------------------------------------------------------------- 00:0000' 0000000000000000> : .space 128 STACK: ; Top of stack area ;=============================================================================== ; Power On Reset Handler ;------------------------------------------------------------------------------- .code .org $f000 .longa off .longi off RESET: 00:F000 78 : sei 00:F001 D8 : cld native 00:F002 18 + clc 00:F003 FB + xce long_ai 00:F004 C230 + rep #M_FLAG|X_FLAG + .longa on + .longi on 00:F006 A9???? : lda #STACK 00:F009 1B : tcs 00:F00A A06400 : ldy #100 Portable 65xx Assembler [16.06] repeat 00:F00D A20000 : ldx #0 repeat 00:F010 CA : dex 00:F011 D0FD : until eq 00:F013 88 : dey 00:F014 D0F7 : until eq 00:F016 42FF : wdm #$ff 00:F018 80E6 : bra RESET ;=============================================================================== ; Dummy Interrupt Handlers ;------------------------------------------------------------------------------- IRQN: COPN: ABORTN: NMIN: BRKN 00:F01A 80FE : bra $ COP: ABORT: NMI: IRQBRK: 00:F01C 80FE : bra $ ;=============================================================================== ; Vectors ;------------------------------------------------------------------------------- .org $ffe0 00:FFE0 00000000 : .space 4 ; Reserved 00:FFE4 1AF0 : .word COPN ; $FFE4 - COP(816) 00:FFE6 1AF0 : .word BRKN ; $FFE6 - BRK(816) 00:FFE8 1AF0 : .word ABORTN ; $FFE8 - ABORT(816) 00:FFEA 1AF0 : .word NMIN ; $FFEA - NMI(816) 00:FFEC 0000 : .space 2 ; Reserved 00:FFEE 1AF0 : .word IRQN ; $FFEE - IRQ(816) 00:FFF0 00000000 : .space 4 00:FFF4 1CF0 : .word COP ; $FFF4 - COP(C02) 00:FFF6 0000 : .space 2 ; $Reserved 00:FFF8 1CF0 : .word ABORT ; $FFF8 - ABORT(C02) 00:FFFA 1CF0 : .word NMI ; $FFFA - NMI(C02) 00:FFFC 00F0 : .word RESET ; $FFFC - RESET(C02) 00:FFFE 1CF0 : .word IRQBRK ; $FFFE - IRQBRK(C02) .end Portable 65xx Assembler [16.06] Symbol Table ABORT 0000F01C | __6501__ 00000000 ABORTN 0000F01A | __6502__ 00000000 BRKN 0000F01A | __65832__ 00000000 B_FLAG 00000010 | __65C02__ 00000000 COP 0000F01C | __65SC02__ 00000000 COPN 0000F01A | C_FLAG 00000001 C_FLAG 00000001 | __65816__ 00000001 D_FLAG 00000008 | Z_FLAG 00000002 IRQBRK 0000F01C | I_FLAG 00000004 IRQN 0000F01A | D_FLAG 00000008 I_FLAG 00000004 | B_FLAG 00000010 M_FLAG 00000020 | X_FLAG 00000010 NMI 0000F01C | M_FLAG 00000020 NMIN 0000F01A | V_FLAG 00000040 N_FLAG 00000080 | N_FLAG 00000080 RESET 0000F000 | STACK 00000080' STACK 00000080' | RESET 0000F000 V_FLAG 00000040 | ABORTN 0000F01A X_FLAG 00000010 | BRKN 0000F01A Z_FLAG 00000002 | COPN 0000F01A __6501__ 00000000 | IRQN 0000F01A __6502__ 00000000 | NMIN 0000F01A __65816__ 00000001 | ABORT 0000F01C __65832__ 00000000 | COP 0000F01C __65C02__ 00000000 | IRQBRK 0000F01C __65SC02__ 00000000 | NMI 0000F01C