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

📄 sma_copylongs.s

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 S
字号:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; $Workfile:   SMA_copylongs.s  $
; $Revision:   1.3  $
; $Author:   BarnettH  $
; $Date:   Jun 10 2002 15:16:06  $
; 
; Project: General Utilities
; 
; Description:
;   SMA_copylongs function
; 
; Revision History:
; $Log:   //smaicnt2/pvcs/VM/CHIPS/archives/SOC/Source/SMA_copylongs.s-arc  $
; 
;    Rev 1.3   Jun 10 2002 15:16:06   BarnettH
; Changed register symbols to "a" synonyms.
; Revised source/destination testing to be more straightforward.
; Ensured successful copy returned zero even on non-word-aligned length.
; Added "Processing" comment
; 
;    Rev 1.2   Jun 05 2002 19:25:10   BarnettH
; Revised to properly determine copy directiion on addresses that have BIT 31 set (are "negative")
; 
;    Rev 1.1   Jun 05 2002 11:07:52   BarnettH
; Changed name of routine to SMA_copylongs
; 
;    Rev 1.0   May 22 2002 16:21:02   BarnettH
; Initial revision.
;  
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;  
;   Copyright (c) 2002 Sharp Microelectronics of the Americas
; 
;   All rights reserved
; 
;   SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION
;   OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE,
;   AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES,
;   SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE.
; 
;   SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY
;   FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A
;   SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT.  USE OF THIS SOURCE
;   FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS.
; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; word SMA_copylongs (a1, a2, a3)
;
; Purpose:
;   Copies a1 bytes word by word from [a2] to [a3]
;   Copies words anywhere, and performs copy ascending or descending
;     in case of overlay; handles non-word-aligned length.
;
;   Uses a1, a2, a3, r12 registers
;   Destroys contents of a1, a2, a3, r12 registers
;
; Processing:
;   Check for nothing to copy
;   Check for source address word aligned, return -1 if not
;   Check for destination address word aligned, return -1 if not
;   Compare source and destination addresses
;   If source is above destination, perform an ascending copy
;   If source is below destination, perform an descending copy
;   Retrun 0
;
; Parameters:
;   a1 - length in bytes
;   a2 - source beginning address, must be word aligned
;   a3 - destination beginning address, must be word aligned
;
; Outputs: None.
;
; Returns:
;     -1 in a1 if source or destination is not word aligned.
;      0 in a1 if copy successful.
;      Calling length argument in a1 if copy not necessary.
;
; C Prototype:
; int SMA_copylongs (unsigned int length,
;                    unsigned int * source,
;                    unsigned int * destination)
;
; Notes: 
;    (1) ATPCS conformant; callable from C or assembly.
;    (2) Does not use the stack; may be called with no stack
;        initialized.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    AREA    UTILS_ASM, CODE, ALIGN=2

    EXPORT  SMA_copylongs

SMA_copylongs   ROUT 
    CMP     a1, #0
    BEQ     %F89  ; nothing to copy
    ; check for source word aligned
    TST     a2,#3
    MVNNE   a1,#0
    BNE     %F89   ; return -1 if source not word aligned
    ; check for destination word aligned
    TST     a3,#3
    MVNNE   a1,#0
    BNE     %F89   ; return -1 if destination not word aligned
    ; compare source and destination addresses
    CMP     a3, a2
    BEQ     %F89   ; if in place, don't copy, just return
    BHI     %F85   ; destination is above, do descending copy

    ; perform ascending copy
80  LDR     r12, [a2], #4
    STR     r12, [a3], #4
    SUBS    a1, a1, #4
    BGT     %B80
    MOV     a1, #0
    B       %F89

    ; perform descending copy
85  ANDS    r12,a1,#3  ; check for length word aligned
    ADDNE   a1,a1,#4   ; if it wasn't, add a word
    BICNE   a1,a1,#3   ; if it wasn't, word align length
    ADD     a2,a2,a1   ; start from top of area
    ADD     a3,a3,a1   ; copy to top of area
86  LDR     r12, [a2,#-4]!
    STR     r12, [a3,#-4]!
    SUBS    a1, a1, #4
    BGT     %B86
    MOV     a1, #0

    ; return
89  MOV     pc, lr
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; End SMA_copylongs function
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    END

⌨️ 快捷键说明

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