start.asm

来自「how to use display powertip PG 320x240」· 汇编 代码 · 共 102 行

ASM
102
字号
;;
;; C166/ST10 startup code generated by EDE for project pg320240
;;
;; If modifications are needed, disable generation of the startup code in EDE:
;; In the EDE Project Options dialog select Application, and then Startup. Make
;; sure the checkbox 'Generate system startup code and add it to project' is not
;; checked. Note that changes in EDE will now no longer be reflected in the
;; startup code. Also be aware that the modifications will be overwritten when
;; the checkbox is enabled again.
;;

$EXTEND
$CASE
$GENONLY
$DEBUG
$NOLOCALS
$CHECKCPU16
$CHECKBUS18
$NOMOD166				; disable the internal set of SFRs
$STDNAMES(reg276.def)		; define SFRs

$INCLUDE(head.asm)			; Generic definitions (see product include dir)
$INCLUDE(_c_init.asm)			; Initialize C variables

	NAME	CSTART			; module name

	PUBLIC	__IDLE			; cstart end
	PUBLIC	__EXIT			; address to jump to on 'exit()'
	EXTERN	_main:NEAR		; start label user program
	EXTERN __C_INIT:NEAR

__CSTART_PR	SECTION CODE WORD PUBLIC 'CPROGRAM'
__CSTART	PROC TASK __CSTART_TASK INTNO __CSTART_INUM = 0

	MOV	ADDRSEL1, #0x0406
	BFLDL	BUSCON1, #0xFF, #0x04AE&0xFF
	BFLDH	BUSCON1, #0xF6, #(0x04AE>>8)&0xFF
	BFLDL	SYSCON, #0xFF, #0x0184&0xFF
	BFLDH	SYSCON, #0xFF, #(0x0184>>8)&0xFF
	EXTR	#1
	MOV	XPERCON, #0x000D
@IF( ( 0x000D & 0x07D3 ) * ( 0x0184 & 0x0004 ) )
	@_MOVE ( XPEREMU, #0x000D, R0 )	; initialize XPEREMU
@ENDI
	
	ATOMIC	#3
	MOV	SP,	#?SYSSTACK_TOP		; Set stack pointer.
	MOV	STKOV,	#?SYSSTACK_BOTTOM + 6*2	; Set stack overflow pointer.
	MOV	STKUN,	#?SYSSTACK_TOP		; Set stack underflow pointer.

	MOV	CP,	#CSTART_RBANK		; Set context pointer.
	NOP			

	MOV	DPP1, #PAG C166_XGROUP	; set DPP1 to page of user stack / xnear data
	MOV	R0, #POF (?USRSTACK_TOP - 2) + 0x4002	; set user stack pointer
	DISWDT				;  Disable watchdog timer

	EINIT				; End of initialization

@SET( BIT_INIT, 0 )			; disable(0)/enable(1) initialization of bit
					; variables at startup
@_CALL(__C_INIT, R1)			; initalization of global/static data

	BSET	IEN			; allow monitor to break application

	MOV	R12, #0			; set argc to 0
	MOV	R13, #0			;
	MOV	R14, #0			; set argv[] to 0

@_CALL( _main, R1)

; The exit() function causes normal program termination to occur. First, all 
; functions registered by the atexit() function are called in the reverse 
; order. Next, all open streams with unwritten buffered data are flushed, all 
; open streams are closed and all files created by the tmpfile() function are 
; removed. The status value passed to exit is returned in R4.
__EXIT: LABEL FAR			; the exit() or abort() function jumps
					; to this entry.
__IDLE: IDLE				; Power down CPU until peripheral inter-
					; rupt or external interrupt occurs.
	JMPR	CC_UC, __IDLE		; set idle mode again.
	RETV				; Virtual return.
__CSTART	ENDP
__CSTART_PR	ENDS


C166_US	SECTION	DATA WORD GLBUSRSTACK 'CUSTACK'
	DS	2			; Allocate a user stack of at least 2 bytes
C166_US	ENDS

C166_DGROUP	DGROUP	__DUMMY
__DUMMY	SECTION DATA WORD PUBLIC 'CNEAR'
__DUMMY	ENDS
C166_XGROUP	DGROUP	__XDUMMY,C166_US
__XDUMMY SECTION DATA WORD PUBLIC
__XDUMMY ENDS

CSTART_RBANK	REGDEF R0-R15		; Register usage
		SSKDEF	0	; System stack size

		END

⌨️ 快捷键说明

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