⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 led.asm

📁 6502 assembly lanuage for SPC122A
💻 ASM
字号:
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **
;*                                                                      *
;*                                                                      *
;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * **
		.linklist
		.symbols
		.CODE
; ================================
; Define System Clock
; ================================
SystemClock:	equ		4000000

; ================================
; Define SPC Body
; ================================
SPC41A:		equ		1

		.Include	Hardware.inh

; ================================
; Define
; ================================
CharWidth:	equ		06H


		.PAGE0
		
; ================================
; RAM Variables Define Area
; ================================
		.ORG		080H
		
RegRan:		ds		2
R_IntFlags:	ds		1
R_CurrInt:	ds		1

Row_PtrL	ds		1
Row_PtrH	ds		1
CountDown1	ds		1		;Use to count how long no trigger is received
CountDown2	ds		1		;   to determine if i-top is still rotating 
SleepCntL	ds		1
SleepCntH	ds		1

;================================
; Include all header files
; Sunplus recommends not modify
; this section
;================================
		.Include	IO.inh

D_LastRAM:	equ		$

		.CODE
		.ORG		00H
		db		0FFH
		.ORG		600H

;//////////////////////////////////////////////
; Program start from location $600
; Functions include all I/O initializations,
; Interrupt initializations and Wakeup
; Procedures.
; Power On Wakeup: It will clear all RAM
;                  and reinitialize
;                  all I/O and interrupts.
;//////////////////////////////////////////////
V_Reset:
		sei				;Disable interrupt signal
		ldx		#FFH		;Initialize stack pointer
		txs
		lda		#C0H		;Clear all interrupt flag
		sta		R_IntFlags
		sta		P_Ints		;Disable WatchDog
		%WakeUp		KeyWakeUpEntry
		
; ===============================
; Power On Wake Up
; Clear all RAM
; A: Initialized RAM value
; X: Start location of RAM
; ===============================
L_PowerOn:
		lda		#00H		;Acc <--- Initial value
		ldx		#80H		;X <--- RAM start location
		%ClearAllRAM

KeyWakeUpEntry:
;====================================
; For power on wake up
; Or key wake up I/O initializations
; %IoWakeUpInitial
;====================================
		%IoWakeUpInitial
		lda		R_IntFlags
		sta		P_Ints

		;---Set Timer A---
		lda		#01H
		sta		P_TmAL
		lda		#00H
		sta		P_TmAH
		
		cli				;Enable interrupt		

;//////////////////////////////////////////////////////////
;     Program: main routine
;//////////////////////////////////////////////////////////
Main_Loop:      	
		jmp     	Main_Loop
		
;=================== include sub-routine file ===================
	


;//////////////////////////////////////////////////////////
; Function Name: V_Irq
; Purpose      : Inetrrupt Service Routine
;//////////////////////////////////////////////////////////
V_Irq:
		pha				;Push A onto stack
		txa
		pha				;Push X onto stack
		
		lda		P_Ints
		sta		R_CurrInt	;Save current interrupt status
		eor		#00111111b	;Clear interrupt, make sure CPU can
						;still	receive other interrupts by EOR
		sta		P_Ints
		lda		R_IntFlags	;Re-initialize interrupt control register
		sta		P_Ints
		lda		R_CurrInt	;Read current interrupt status
		and		#00100000b	;Check if TimerA interrupt occurred
		beq		L_NotTimerA
		
L_TimerAInt:
        ;---Process Timer A interrupt by user define---	

L_NotTimerA:
		lda		R_CurrInt
		and		#00001000b	;Check if 4KHz interrupt occurred
		beq		L_NotCPU4K	

L_CPU4KInt:
        ;---Process 4KHz interrupt by user define---

L_NotCPU4K:
		lda		R_CurrInt
		and		#00000100b	;Check if 500Hz interrupt occurred
		beq		L_NotCPU500

L_CPU500Int:
        ;---Process 500Hz interrupt by user define---

L_NotCPU500:
		lda		R_CurrInt
		and		#00000010b	;Check if 62.5Hz interrupt occurred
		beq		L_NotCPU62_5

L_CPU62_5Int:
        ;---Process 62.5Hz interrupt by user define---

L_NotCPU62_5:
		pla
		tax
		pla

V_Nmi:
		rti
		
; *** Table Start ****************************
; *** Table End ******************************

;=============================================
; Purpose: Include all program bodies
; Note: Sunplus recommends not to modify this
;       secion if possible.
;=============================================
    .DB     'SPCHL', 0
T_RhythmLowAddr:
    DS      30
    .DB     'SPCHH', 0
T_RhythmHighAddr:
    DS      30
    .DB     'SPCHB', 0
T_RhythmBankAddr:
    DS      30

    db      'PEND', 0
;=============================================
; Purpose: Fill in Interrupt Vector
;
; Note   : Sunplus recommends not to
;          modify this section if possible.
;=============================================
.org    7ffaH
    dw      V_Nmi
    dw      V_Reset
    dw      V_Irq

.org    0fffah
    dw      V_Nmi
    dw      V_Reset
    dw      V_Irq

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -