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

📄 crt9.asm

📁 用ST92163开发的鼠标
💻 ASM
字号:
; Version 1.40
;
; Template start-up file for 1 microcontroller applications
;
; - linked with option -I to copy initial .data values from .text section
;
; Note that an instruction which loops forever is generated after 'main'.


.include "page_0.inc"
.include "mmu.inc"
.include "system.inc"
.include "rccu.inc"
.include "mem_mode.inc"
.include "mic_mode.inc"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; If you want to use one or more USB un-used vector location(s)
; you can modify one of the definition hereafter
; by change the name "Dummy" to your vector name
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.defstr ep1_vec "Dummy" ; USB_VECTOR + 0x22
.defstr ep2_vec "Dummy" ; USB_VECTOR + 0x24
.defstr ep3_vec "Dummy" ; USB_VECTOR + 0x26
.defstr ep4_vec "Dummy" ; USB_VECTOR + 0x28
.defstr ep5_vec "Dummy" ; USB_VECTOR + 0x2A
.defstr ep6_vec "Dummy" ; USB_VECTOR + 0x2C
.defstr ep7_vec "Dummy" ; USB_VECTOR + 0x2E
.defstr ep8_vec "Dummy" ; USB_VECTOR + 0x30
.defstr ep9_vec "Dummy" ; USB_VECTOR + 0x32
.defstr ep10_vec "Dummy" ; USB_VECTOR + 0x34
.defstr ep11_vec "Dummy" ; USB_VECTOR + 0x36
.defstr ep12_vec "Dummy" ; USB_VECTOR + 0x38
.defstr ep13_vec "Dummy" ; USB_VECTOR + 0x3A
.defstr ep14_vec "Dummy" ; USB_VECTOR + 0x3C
.defstr ep15_vec "Dummy" ; USB_VECTOR + 0x3E

.include "usb_vec.inc"

;
; CICR = IT disabled + Nested Mode + CPL = 7
; MODER = both stacks in memory + clock divided by 2
; WCR = zero wait state + watchdog disabled
;
	INIT_CICR = 0x87	; GCEN=1 (16b multifunction timer enabled) CPL=7
	INIT_MODER = 0x00	; DIV2=0 (OSCIN/2), PRS2-0=0
	INIT_WCR = 0x40		; WDGEN=1 (watchdog disabled)

	.text
	.word	__Reset

	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy

	.word	Dummy	; 10h
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	USB_Istr

	USB_VECTORS	; Total 16 words

	.word	Dummy	; 40h
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy
	.word	Dummy

; Reset routine
; WARNING : it is important to set rr12 to something NOT zero.
; This is because for the debugger, a null frame pointer means
; that the function has no parent frame (ie cannot go up). This is OK
; for the main routine, but not for routines called by main.
; If -fomit-frame-pointer is used for compiling, rr12 could not
; be set in main, nor in functions called by main...
; Furthermore, it seems a good idea to initialize the current frame
; pointer to the current stack pointer.
;
	.global __Reset
	.global __Halt
__Reset:
	spp	#0
	ld	WCR, #INIT_WCR		; WCR = zero wait state
;
; System registers initialization in group 0xE (R224 to R239)
; init clock mode and select external stacks in data memory
; Set register pointer to group 0xD
;
	ld	MODER, #INIT_MODER
	ld	CICR, #INIT_CICR

	spp	#21
	ld	DPR3_P,#0x83

	spp	#0

	srp1	#27
	srp	#26

;
;
	sdm				; set data memory
	ldw	SSPR,#_stack_end	; setup stack

	ldw	rr0, #0xcf		; Clear register R207 to R1

init_reg_stack:
	ld	(r1), r0
	djnz	r1, init_reg_stack

	ldw	USPR,#_user_stack_end	; setup user stack
;
; Section to initialize the data, bss and stack sections.
; Note: ld9 creates the following symbols :
;
;	_data_start	points to the start of the run time data area,
;	_data_end	points to the end of the run time data area,
;	_bss_start	points to the start of the run time bss area,
;	_bss_end	points to the end of the run time bss area,
;	_text_start	points to the start of the text segment,
;	_text_end	points to the end of the text segment,
;	_stack_start	points to the start of the stack segment,
;	_stack_end	points to the end of the stack segment.
;
__InitDataBss:

;
; Note: option I must be used with ld9 in order to get the
; initialized data information at the end of the text section (in ROM).
;
; In that case, '_text_end - (_data_end - _data_start)' gives the start
; address of the initialized data information in the text segment.
;
; Init .data area
;
	ldw	rr0,#_data_start	; start of run-time data area
	ldw	rr4,#_data_end		; end of run time data area
	subw	rr4,rr0			; rr4 = length of initialized data
	jrz	no_data			; if empty
	ldw	rr2,#_text_end		; end ROMed data area
	subw	rr2,rr4			; start of ROMed data area
init_data:
	lddp	(rr0)+,(rr2)+		; init data section
	dwjnz	rr4,init_data
no_data:

;
; Init .bss section

; (here r4 = 0)
;

	ldw	rr0,#_bss_start		; start of run-time bss area
	ldw	rr2,#_bss_end		; end of run time bss area
	subw	rr2,rr0			; rr2 = length of bss area
	jrz	no_bss			; if bss is empty
init_bss:
	ld	(rr0)+,r4		; clear whole bss section (Data space)
	dwjnz	rr2,init_bss
no_bss:
;
; Init stack section (not really necessary, but cleaner)
; (here r4 = 0)
;
	ldw	rr0,#_stack_start	; start of run-time stack area
	ldw	rr2,#_stack_end		; end of run time stack area
	subw	rr2,rr0			; rr2 = length of stack area
	jrz	endinit			; if stack is empty
init_stack:
	ld	(rr0)+,r4		; clear whole stack section (Data space)
	dwjnz	rr2,init_stack

endinit:
;
; disable interrupt and call main routine
;
	di				; disable interrupts
	ldw	rr12,SSPR		; make sure rr12 is NOT zero

	spp	#55			;page 55 acces RCCU control registers
	and	PLLCONF, #11011000b	; internal frequency of 24 MHz
	or	PLLCONF, #00010001b	; 8Mhz * 6 / 2
;	ldw	rr0,#07FFEh		; wait
;	dwjnz	rr0,.			;
	and	CLK_FLAG,#11001011b	;PLL, XT/2
	or	CLK_FLAG,#00001001b	; CSU-CKSEL=1, XT_DIV16=1
	and	CLKCTL,#00000000b	; Reset CLKCTL

__wait_PLL:	; Wait PLL is locked
	tm	CLK_FLAG, #00000010b
	jrz	__wait_PLL

	_call	main
__Halt:
	jr	.			; halt or jp .
;
; End of crt9.asm

⌨️ 快捷键说明

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