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

📄 boot.asm

📁 该代码采用c5400dsp的汇编语言和c语言实现ucos操作系统
💻 ASM
字号:
****************************************************************************
*  BOOT   v3.10                                                             *
*  Copyright (c) 1993-1998 Texas Instruments Incorporated                  *
****************************************************************************
	.c_mode
	.mmregs
CONST_COPY	.set 0
****************************************************************************
*                                                                          *
*   This module contains the following definitions :                       *
*                                                                          *
*         __stack    - Stack memory area                                   *
*         _c_int00   - Boot function                                       *
*         _var_init  - Function which processes initialization tables      *
*                                                                          *
****************************************************************************
        .ref	 cinit, pinit
;        .ref	_load_data, _load_imem 
	.global  _c_int00
	.global  _main, _exit,__STACK_SIZE

****************************************************************************
* Declare the stack.  Size is determined by the linker option -stack.  The *
* default value is 1K words.                                               *
****************************************************************************
__stack:	.usect	".stack",0

****************************************************************************
* FUNCTION DEF : _c_int00                                                  *
*   0) Boot load initialized data and .ext_text sections from flash                                                                       *
*   1) Set up stack                                                        *
*   2) Set up proper status                                                *
*   3) If "cinit" is not -1, init global variables                         *
*   4) call users' program                                                 *
*                                                                          *
****************************************************************************

_c_int00:
****************************************************************************
* boot load initialized data, .ext_text sections from flash                *
* SP, IMR, IFR, SWWSR and PMST registers are set for the _load_imem and    *
* _load_data functions to work correctly, they may be set to other values  *
* after boot load                                                          *
****************************************************************************
	stm	  #0x70,   SP	;setup a small stack for data loader using scratch-pad memory
    stm   #0x0,    IMR	;disable all interrupts
    stm   #0xffff, IFR  ;
	stm   #0x7fe2, PMST	;MP=1, OVLY=1 
	stm   #2208h, SWWSR ;wait state: I/O=2, int_Data=0, asic_Data=1
			            ;Ext_Program=1, int_Program=0 
	
	STM #0x8224, AR0			; Asic[ext_csn]
	NOP							;
	NOP							;
	
	LD #0x3, A					; Enable flash read from program mem
	NOP							;
	NOP							;	
	STL A, *AR0					;
    
;    call  _load_imem	;load instruction from program space if any
;	call  _load_data	;load default data if there is any
****************************************************************************
*  INIT STACK POINTER.  REMEMBER STACK GROWS FROM HIGH TO LOW ADDRESSES.   *
****************************************************************************   
			            
    stm   #2208h, SWWSR ;wait state: I/O=2, int_Data=0, asic_Data=1
			            ;Ext_Program=1, int_Program=0 

	    
	ld	  #1, a		    ;set mode to 1
	stm	  #0x8003, ar2
	nop
	stl   a, *ar2 
	
SET_DSPPLL:				;DSP power on at x1 mode 
	stm		#0b, CLKMD
TstStatu:
	ldm		CLKMD, a
	and		#1b, a
	bc		TstStatu, aneq
;                |        |  
	stm		#0001011111110111b, CLKMD ;switch to PLLx2 mode

	rpt #10000;
		nop;	
	
	STM	#__stack,SP		; set to beginning of stack memory
	ADDM	#(__STACK_SIZE-1),*(SP) ; add size to get to top
	ANDM	#0fffeh,*(SP)		; make sure it is an even address
	
	SSBX	SXM			; turn on SXM for LD #cinit,A

****************************************************************************
* SET UP REQUIRED VALUES IN STATUS REGISTER                                *
****************************************************************************
	SSBX	CPL			; turn on compiler mode bit
	RSBX	OVM			; clear overflow mode bit

****************************************************************************
* SETTING THESE STATUS BITS TO RESET VALUES.  IF YOU RUN _c_int00 FROM     *
* RESET, YOU CAN REMOVE THIS CODE                                          *
****************************************************************************
	LD	#0,ARP
	RSBX	C16
	RSBX	CMPT
	RSBX	FRCT

****************************************************************************
*  IF cinit IS NOT -1, PROCESS INITIALIZATION TABLES			   *
*  TABLES ARE IN PROGRAM MEMORY IN THE FOLLOWING FORMAT:                   *
*                                                                          *
*       .word  <length of init data in words>                              *
*       .word  <address of variable to initialize>                         *
*       .word  <init data>                                                 *
*       .word  ...                                                         *
*                                                                          *
*  The cinit table is terminated with a zero length                        *
*                                                                          *
****************************************************************************
	.if	__far_mode
	LDX	#cinit,16,A		
	OR	#cinit,A,A
	.else
	LD	#cinit,A                ; Get pointer to init tables
	.endif

	ADD	#1,A,B
	BC	DONE_CINIT,BEQ		; if (cinit == -1) no init tables

****************************************************************************
*  PROCESS INITIALIZATION TABLES.  TABLES ARE IN PROGRAM MEMORY IN THE     *
*  FOLLOWING FORMAT:                                                       *
*                                                                          *
*       .word  <length of init data in words>                              *
*       .word  <address of variable to initialize>                         *
*       .word  <init data>                                                 *
*       .word  ...                                                         *
*                                                                          *
*  The init table is terminated with a zero length                         *
*                                                                          *
****************************************************************************
	BD 	START_CINIT		; start processing
	RSBX	SXM			; do address arithmetic unsignedly
	nop	

LOOP_CINIT:
	READA	*(AR2)			; AR2 = address
	ADD	#1,A			; A += 1

	RPT	*(AR1)			; repeat length+1 times
	READA	*AR2+			; copy from table to memory

	ADD	*(AR1),A		; A += length (READA doesn't change A)
	ADD	#1,A			; A += 1

START_CINIT:
	READA	*(AR1)			; AR1 = length
	ADD	#1,A			; A += 1
	BANZ	LOOP_CINIT,*AR1-	; if (length-- != 0) continue 
DONE_CINIT:

****************************************************************************
*  IF pinit IS NOT -1, PROCESS INITIALIZATION TABLES                       *
*  TABLES ARE IN PROGRAM MEMORY IN THE FOLLOWING FORMAT:                   *
*                                                                          *
*       .word  <address of initialization routine to call>                 *
*       .word  ...                                                         *
*                                                                          *
*  The pinit table is terminated with a NULL pointer                       *
*                                                                          *
****************************************************************************
	SSBX	SXM
	nop

	.if	__far_mode
	LDX	#pinit,16,A
	OR	#pinit,A,A
	.else
        LD      #pinit,A                ; A = &pinit table
	.endif

        ADD     #1,A,B                  ; B = A + 1
        BC      DONE_PINIT,BEQ          ; if (pinit == -1) no pinit tables

        PSHM    AL                      ; save PINIT pointer to stack
        PSHM    AL                      ; used to store function ptr
        BD      START_PINIT
	RSBX	SXM
	nop

LOOP_PINIT:
        CALA    B                       ; call function
        LD      @1, A                   ; put PINIT pointer in A

START_PINIT:
        READA   @0                      ; "push" address of function
        LD      @0, B                   ; "pop" address of function
        BCD     LOOP_PINIT,BNEQ         ; if not NULL, loop.
        ADDM    #1,@1                   ; move PINIT pointer (in stack)

        POPM    AL                      ; remove function ptr from stack        
        POPM    AL                      ; remove pinit from stack        

DONE_PINIT:
           
****************************************************************************
*  CALL USER'S PROGRAM                                                     *
****************************************************************************
	.if CONST_COPY
	.if __far_mode                  ; Use far calls for C548 in far mode
	FCALL	_const_init             ; move .const section to DATA mem
        .else
        CALL	_const_init
	.endif
	.endif

	.if __far_mode                  ; Use far calls for C548 in far mode
	FCALL    _main			
	FCALL    _exit			; call exit instead of abort so that
	.else
	CALL    _main			
	CALL    _exit			; call exit instead of abort so that
	.endif

	.if CONST_COPY

****************************************************************************
* FUNCTION DEF : __const_init                                              *
*                                                                          *
*  COPY .CONST SECTION FROM PROGRAM TO DATA MEMORY                         *
*                                                                          *
*   The function depends on the following variables                        *
*   defined in the linker command file                                     *
*                                                                          *
*   __c_load         ; global var containing start                         *
*                      of .const in program memory                         *
*   __const_run      ; global var containing run                           *
*                      address in data memory                              *
*   __const_length   ; global var length of .const                         *
*                      section                                             *
*                                                                          *
****************************************************************************
        .global __const_length,__c_load
        .global __const_run
_const_init:
 
        .sect ".c_mark"              ; establish LOAD adress of
        .label __c_load             ; .const section
 
        .text
******************************************************
* C54x VERSION                                        *
******************************************************
 
        LD      #__const_length, A
        BC      __end_const,AEQ
        STM     #__const_run,AR2 ; Load RUN address of .const
 
        RPT     #__const_length-1
        MVPD    #__c_load,*AR2+  ; Copy .const from program to data
 
******************************************************
*  AT END OF .CONST SECTION RETURN TO CALLER         *
******************************************************
__end_const:
        RET
        .endif
	.end

⌨️ 快捷键说明

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