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

📄 crt0.s

📁 USBhost source
💻 S
字号:
;
;	H8/300H 僗僞乕僩傾僢僾儖乕僠儞 (ROM壔懳墳)
;

	.h8300h

;---------------------------------------------------
;	僗僞乕僩傾僢僾儖乕僠儞
;--------------------------------------------------
	.section .text
	.global _start
_start:
	mov.l   #_stack, sp		; 僗僞僢僋億僀儞僞弶婜壔

	mov.b	#0xff:8, r0l		; ABWCR 俉價僢僩僶僗
	mov.b	r0l, @0xffffec
	mov.b	#0xFf:8, r0l
	mov.b	r0l, @0xffffed		; ASTCR WAIT3w
	mov.b	#0xf3:8, r0l
	mov.b	r0l, @0xffffee		; WCR
	mov.b	#0xff:8, r0l
	mov.b	r0l, @0xffffef		; WCER
	mov.b	#0x3f:8, r0l
	mov.b	r0l, @0xffff5f		; CSCR CS4,5桳岠
	mov.b	#0xff:8, r0l		; 俹侾慡價僢僩弌椡
	mov.b	r0l, @0xffffc0
	mov.b	#0xff:8, r0l		; 俹俀慡價僢僩弌椡
	mov.b	r0l, @0xffffc1
	mov.b	#0x00:8, r0l
	mov.b	r0l, @0xffffca
	mov.b	r0l, @0xffffcb
	mov.b	#0xff:8, r0l		; 俹俆慡價僢僩弌椡
	mov.b	r0l, @0xffffc8
	mov.b	#0xf8:8, r0l		; 俹俇 2-0擖椡
	mov.b	r0l, @0xffffc9
	mov.b	#0x00:8, r0l
	mov.b	r0l, @0xffffcf		; 俹俉弶婜抣
	mov.b	#0x1f:8, r0l
	mov.b	r0l, @0xffffcd		; 俹俉弌椡
	mov.b	#0x00:8, r0l
	mov.b	r0l, @0xffffd3		; 俹俙弶婜抣
	mov.b	#0xf9:8, r0l
	mov.b	r0l, @0xffffd1		; 俹俙弌椡


;;	弶婜壔僨乕僞椞堟(DATA僙僋僔儑儞)弶婜壔
init_data:
	mov.l   #__idata_end, er0
	sub.l   #__idata_start, er0
	beq     init_bss
	mov.l   #__idata_start, er1
	mov.l   #__data_start, er2
init_data1:
	mov.b   @er1+, r3l
	mov.b   r3l, @er2
	inc.l   #1, er2
	dec.l   #1, er0
	bne     init_data1

;;	旕弶婜壔僨乕僞椞堟(BSS)僋儕傾
init_bss:
	xor.b   r2l, r2l
	mov.l   #_end, er0
	sub.l   #_bss_start, er0
	beq     call_main
	mov.l   #_bss_start, er1
init_bss1:
	mov.b   r2l, @er1
	inc.l   #1, er1
	dec.l   #1, er0
	bne     init_bss1

	;; 弶婜壔丆儊僀儞
call_main:
	ldc.b	#0x0, ccr		; 妱傝崬傒嫋壜
	jsr	@_main
	ldc.b	#0x80, ccr		; 妱傝崬傒嬛巭

_endless:				; 儊僀儞傪敳偗偨偲偒梡
	jmp     @_endless

_wait10us:
;
;	侾侽兪倱偺僨傿儗僀乮僜僼僩僨傿儗僀乯
;	妱傝崬傒偼擖傞偺偱拲堄
;	25MHz...250T
;	void	wait10us( void )
;
	.global _wait10us
_wait10us:				; 10
	push.l	er0			; 10
	push.l	er1			; 10
	push.l	er2			; 10
	;
	mov.l	#0:32, er1		; 6
	mov.w	#1:16, e0		; 4
	mov.w	#4:16, r0		; 4
wait10us_l:
	divxs.w	e2, er1			; 24
	sub.w	#1:16, r0		; 4
	bne	wait10us_l		; 4	; 32 * 4 = 128
	;
	divxs.w	e2, er1			; 24
	nop				; 2
	nop				; 2
	pop	er2			; 10
	pop	er1			; 10
	pop	er0			; 10
	rts				; 10

;
;	侾侽侽兪倱偺僨傿儗僀乮僜僼僩僨傿儗僀乯
;	妱傝崬傒偼擖傞偺偱拲堄
;	25MHz...2500T
;	void	wait100us( void )
;
	.global	_wait100us
_wait100us:				; 10
	push.l	er0			; 10
	push.l	er1			; 10
	push.l	er2			; 10
	;
	mov.l	#0:32, er1		; 6
	mov.w	#1:16, e0		; 4
	mov.w	#75:16, r0		; 4
wait100us_l:
	divxs.w	e2, er1			; 24
	sub.w	#1:16, r0		; 4
	bne	wait100us_l		; 4	; 32 * 75 = 1792
	;
	nop				; 2
	nop				; 2
	nop				; 2
	pop	er2			; 10
	pop	er1			; 10
	pop	er0			; 10
	rts				; 10

	.section .stack
_stack:

	.end

⌨️ 快捷键说明

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