                        ; Demo Assembly Program - Edward Cheung
                        ; Demo System 11 Assembly Program 
                        ; March 2021 - ed@edcheung.com
                        ; Typical Assemble command c:\Progra~1\a68\a68 full.asm -l full.lst -o full.hex
                        
                        ; Data section
   0000                 		ORG $0000	; Bottom of ROM
   0000   11 22 33 44   		FCB $11,$22,$33,$44,$55,$66,$77,$88
   0004   55 66 77 88   
                        		
                        ; Top of main to demo read/writes
   3000                 MAIN	ORG	$3000		;@B000 to CPU
   3000   b6 80 00      		LDA A $8000	; Read bottom of ROM and write to RAM
   3003   97 01         		STA A $0001	;   0001 <- 8000 (memory location)
   3005   96 01         		LDA A $0001	;   0001?
   3007   86 55         		LDA A #$55	; Write constant to RAM
   3009   97 01         		STA A $0001	;   0001 <- 0x55 (literal)
   300b   96 01         		LDA A $0001	;   0001?
   300d   8e 07 ff      		LDS #$07FF	; Set location of Stack
   3010   7e b0 00      		JMP $B000
                        
                        ; Interrupt to light LED2 on pushbutton
   4000                 NMI_HANDLER	ORG $4000	;@C000 to CPU
   4000   86 30         		LDA A #$30	; Access DDR Port A
   4002   b7 28 01      		STA A $2801	;   2801 <- 0x30 (literal)
   4005   86 ff         		LDA A #$FF	; All as outputs
   4007   b7 28 00      		STA A $2800	;   2800 <- 0xFF (literal)
   400a   86 00         		LDA A #$00	; Access Data Port
   400c   b7 28 01      		STA A $2801	;   2801 <- 0x00 (literal)
   400f   86 ff         		LDA A #$FF	; All outputs high to light LED2
   4011   b7 28 00      		STA A $2800	;   2800 <- 0xFF (literal)
   4014   0e            		CLI		; Allow IRQ to fire
   4015   7e b0 00      		JMP $B000	; Back to MAIN
                        
                        ; Interrupt to clear LED2
   2000                 IRQ_HANDLER	ORG $2000	;@A000 to CPU
   2000   86 00         		LDA A #$00	; All outputs low to off LED2
   2002   b7 28 00      		STA A $2800	;  2800 <- 0x00
   2005   7e b0 00      		JMP $B000	; Back to MAIN
                        
                        ; Set up Vectors
   7ff8                 		ORG $7FF8
   7ff8   a0 00         		FCB $A0,$00	; Periodic Int: IRQ Vector @ $2000
   7ffa   b0 00         		FCB $B0,$00	; SW int (not used)
   7ffc   c0 00         		FCB $C0,$00	; Push button: NMI @ $4000
   7ffe   b0 00         		FCB $B0,$00	; Power Up: RESET @ $3000
   8000                 		END
2000  IRQ_HANDLER    3000  MAIN          4000  NMI_HANDLER    
