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

📄 copyalgo.asm

📁 TMS320C2000Flash操作
💻 ASM
📖 第 1 页 / 共 2 页
字号:
;--------------------------------------------------------------------------------------------------
; Restore the hardware stack and exit to caller.
;--------------------------------------------------------------------------------------------------
;STACK_RESTORE:
        LAR     AR2,#flashAlgoVars.STACK7       ;Point AR2 to the last of the stored stack contents
        MAR     *,AR2                           ;Make AR2 the current AR
        
        RPT     #7                              ;Restore ALL stack locations.
        PSHD    *-
        MAR     *,AR1                           ;Make AR1 the current AR
        RET                                     ;Return to caller




;-------------------------------------------------------------------------------
; copyProgramAlgo:
; This is the implementation of the ASM and C callable copy routine to copy
; the flash algorithms to the run address from the load address.
;-------------------------------------------------------------------------------
COPY_PROGRAM_ALGO:                          ;Assembly language call label.
_copyProgramAlgo:                           ;C-language call label.

        LDP     #flashAlgoVars.source       ;Point DP to the copy variables.

;STACK_SAVE:
        LAR     AR2,#flashAlgoVars.STACK0   ;Use AR2 to save the hardware stack.
        MAR     *,AR2                       ;Make AR2 the current AR

        RPT     #7                          ;Save all the 8 hardware stack locations
        POPD    *+                          ;into RAM block.


;-------------------------------------------------------------------------------
; Process the main portion of the Program algorithm
;-------------------------------------------------------------------------------

        LACC    #ProgramAlgoStartMain       ;Point to the source of the clear
        SACL    flashAlgoVars.source        ;algorithm.

        LACC    #ProgramAlgoEndMain         ;Compute the length of the algo
        SUB     #ProgramAlgoStartMain       ;to be copied, and then store 
        SACL    flashAlgoVars.counter       ;it back to the counter.

        LACC    #ProgramAlgoRunMain         ;Get the run address for the 
                                            ;main clear algorithm.
        SACL    flashAlgoVars.dest          ;Store the destination address.

        CALL    COPY_LOOP                   ;Call the core copy function.

;-------------------------------------------------------------------------------
; Copy the relocation sensitive portion of the Erase algorithm
;-------------------------------------------------------------------------------
        LACC    #ProgramAlgoStartSpl        ;Point to the source of the clear
        SACL    flashAlgoVars.source        ;algorithm.

        LACC    #ProgramAlgoEndSpl          ;Compute the length of the algo
        SUB     #ProgramAlgoStartSpl        ;to be copied, and then store 
        SACL    flashAlgoVars.counter       ;it back to the counter.

        LACC    #ProgramAlgoRunSpl          ;Get the run address for the 
                                            ;main clear algorithm.
        SACL    flashAlgoVars.dest          ;Store the destination address.

        CALL    COPY_LOOP                   ;Call the core copy function.


;--------------------------------------------------------------------------------------------------
; Restore the hardware stack and exit to caller.
;--------------------------------------------------------------------------------------------------
;STACK_RESTORE:
        LAR     AR2,#flashAlgoVars.STACK7       ;Point AR2 to the last of the stored stack contents
        MAR     *,AR2                           ;Make AR2 the current AR
        
        RPT     #7                              ;Restore ALL stack locations.
        PSHD    *-
        MAR     *,AR1                           ;Make AR1 the current AR
        RET                                     ;Return to caller

;-------------------------------------------------------------------------------
; copyControlKernel:
; This is the implementation of the ASM and C callable copy routine to copy
; the flash algorithms to the run address from the load address.
;-------------------------------------------------------------------------------
COPY_KERNEL:                                ;Assembly language call label.
_copyKernel:                                ;C-language call label.

        LDP     #flashAlgoVars.source       ;Point DP to the copy variables.

;STACK_SAVE:
        LAR     AR2,#flashAlgoVars.STACK0       ;Use AR2 to save the hardware stack.
        MAR     *,AR2                           ;Make AR2 the current AR

        RPT     #7                              ;Save all the 8 hardware stack locations
        POPD    *+                              ;into RAM block.

;-------------------------------------------------------------------------------
; Process the main portion of the Erase algorithm
;-------------------------------------------------------------------------------

        LACC    #KernelStart                ;Point to the source of the clear
        SACL    flashAlgoVars.source        ;algorithm.

        LACC    #KernelEnd                  ;Compute the length of the algo
        SUB     #KernelStart                ;to be copied, and then store 
        SACL    flashAlgoVars.counter       ;it back to the counter.

        LACC    #KernelRun                  ;Get the run address for the 
                                            ;main clear algorithm.
        SACL    flashAlgoVars.dest          ;Store the destination address.

        CALL    COPY_LOOP                   ;Call the core copy function.

;--------------------------------------------------------------------------------------------------
; Restore the hardware stack and exit to caller.
;--------------------------------------------------------------------------------------------------
;STACK_RESTORE:
        LAR     AR2,#flashAlgoVars.STACK7       ;Point AR2 to the last of the stored stack contents
        MAR     *,AR2                           ;Make AR2 the current AR
        
        RPT     #7                              ;Restore ALL stack locations.
        PSHD    *-
        MAR     *,AR1                           ;Make AR1 the current AR
        RET                                     ;Return to caller


        











;-------------------------------------------------------------------------------
; COPY_LOOP:
;   This function forms the base implementation for the copy routines that are
; used to copy the flash algorithms from their load address to their run 
; addresses. 
;-------------------------------------------------------------------------------


COPY_LOOP:

        LACC    flashAlgoVars.source        ;Get the source address in the ACC.

        TBLR    flashAlgoVars.temp          ;Transfer the word into a temorary
                                            ;location

        LACC    flashAlgoVars.dest          ;Get the dest address in the ACC.
        TBLW    flashAlgoVars.temp          ;Transfer the word from temporary
                                            ;storage to the destination.


        LACC    flashAlgoVars.source        ;Increment the source address.
        ADD     #1                          ;
        SACL    flashAlgoVars.source        ;

        LACC    flashAlgoVars.dest          ;Increment destination address.
        ADD     #1                          ;
        SACL    flashAlgoVars.dest          ;

        LACL    flashAlgoVars.counter       ;Decrement the counter.
        SUB     #1                          ;
        SACL    flashAlgoVars.counter       ;

        BCND    COPY_LOOP,NEQ               ;Loop back if more words remain
                                            ;to be copied over.
        RET

   
;Define mark labels for wrapping the KER_text into.
;These are used to define sections into which no code is placed,
;however these are used as placeholders to wrap all the KER_text
;code. This is done to obtain the load address start and end
;for the kernel functions.
;                          
		.sect 	"KER_strt"
		.globl	KernelStart
		.label  KernelStart
		
		NOP
		
	    .sect 	"KER_end"
	    .globl	KernelEnd
	    .label  KernelEnd
	    NOP


 

    

⌨️ 快捷键说明

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