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

📄 bbu_mem_tests.s

📁 关于PXA310的最小系统的程序,初级学习阶段会有所帮助,汇编语言编写的
💻 S
📖 第 1 页 / 共 5 页
字号:
;       No match on value - inform user
;
        mov     r0,     r6      ; copy expected data to r0
        mov     r1,     r4      ; Get address of failed location
        mov     r2,     r8      ; Move actual data to r2
        bl      BBU_MTSP_error  ; Print message
    
12      subs    r5,     r5,     #4      ; decrement byte count
        bne     %B11                    ; Loop until done
;
;       Increment current loop counter and exit if equal to max loop count
;
13      ldr     r5,     =BBU_SMTD_CLC   ; Address of current loop counter
        ldr     r6,     [r5]            ; Fetch this value
        ldr     r7,     =BBU_SMTD_LOOP  ; Address of ending loop count
        ldr     r8,     [r7]            ; Fetch this value
        cmp     r6,     r8              ; Are the loop counts equal?
        bne     %F14                    ; No - skip the return
        ldmfd   sp!,    {r1-r12, pc}    ; YES - return to caller
        
14      add     r6,     r6,     #1      ; NO! - Increment current loop count ...
        str     r6,     [r5]            ; ... and save this value       
        b       %B5                     ; Run test again
;
;       Text Messages for CDP memory tests
;
MTS_CDP_MSG1    DCB     "  0x00000002 - Writing Constant Data Pattern - Pass ",0
MTS_CDP_MSG2    DCB     "  0x00000002 - Reading Constant Data Pattern",0xD,0xA,0
        ALIGN   4
        ENDFUNC
;
;*********************************************************************************
;
;       ****************
;       *              * 
;       * bbu_MTS_CODP * Subroutine
;       *              *
;       ****************
;
; This subroutine performs an "Complement Data Pattern" test on the selected memory

;
; PARAMETER PASSING & REGISTER USE:
;
;       R0 = used for calls to UART subroutines
;       r1 - r8 = available for general use
;       r9  = Starting address of memory test (DO NOT MODIFY!)
;       r10 = Number of bytes to be tested (DO NOT MODIFY!)
;       r11-r12 = available for general use
;       r13 = Stack pointer (sp) - DO NOT MODIFY
;       r14 = Link register (lr) - DO NOT MODIFY
;

bbu_MTS_CODP    FUNCTION

        stmfd   sp!,    {r0-r12, lr}    ; Save r0-r12 and link register on the stack
        ldr     r5,     =BBU_SMTD_CLC   ; Address of current loop counter
        mov     r6,     #1              ; This is pass #1
        str     r6,     [r5]            ; Save this value
        
        mov     r12,    lr              ; Copy the link register into r12
5       ldr     r0,     =MTS_CODP_MSG1  ; Identify test to be run
        bl      BBU_putstr              ; Send string to user
        mov     r0,     r6              ; Get pass number
        mov     r1,     #0              ; Supress leading zeros
        bl      BBU_UDecToAscii         ; Send to user
        bl      BBU_crlf                ; Output a <CR><LF>
        mov     r4,     r9              ; Set up starting address in r4
        mov     r5,     r10             ; Put byte count into r5
        bic     r5,     r5,     #7      ; Make sure bits 2:0 are clear (8 byte increments)
;
;       See if BBU specified starting pattern is to be used
;
        ldr     r1,     =BBU_SMTD_PAT   ; Address of BBU starting pattern
        ldr     r2,     [r1]            ; Fetch starting pattern
        ldr     r1,     =BBU_SMTD_STAT  ; Address of Memory test status word
        ldr     r3,     [r1]            ; Fetch status word
        ands    r3,     r3,     #1      ; Bit 0 set = Use BBU supplied starting pattern
        movne   r6,     r2              ; Use BBU starting pattern        
        ldreq   r6,     =0x7FFF7FFF     ; Load r6 with test default starting pattern
        mvn     r7,     r6              ; Flip all the bits
;
;       Fetch AND mask and OR data word from BBU code
;
        ldr     r1,     =BBU_SMTD_AND   ; Address of AND mask word
        ldr     r2,     [r1]            ; Fetch AND mask
        ldr     r1,     =BBU_SMTD_OR    ; Address of OR data word
        ldr     r3,     [r1]            ; Fetch OR data word
;
;       Update the test patterns as required
;
        and     r6,     r6,     r2      ; AND the starting pattern
        and     r7,     r7,     r2      ; AND the complement patttern
        orr     r6,     r6,     r3      ; OR the starting pattern
        orr     r7,     r7,     r3      ; OR the complement pattern
;
;       Fill memory with the test pattern
;
10      str     r6,     [r4],   #4      ; Store first pattern
        str     r7,     [r4],   #4      ; Store second pattern
        subs    r5,     r5,     #8      ; Decrement byte count
        bne     %B10                    ; Loop until memory is filled
;
;       Read pattern back and check for errors
;
14      ldr     r0,     =MTS_CODP_MSG2  ; Let user know data is being read
        bl      BBU_putstr              ; Send string to user
        mov     r4,     r9              ; Set up starting address in r4
        mov     r5,     r10             ; Put byte count into r5
        bic     r5,     r5,     #7      ; Make sure bits 2:0 are clear (8 byte increments)

11      ldr     r8,     [r4],   #4      ; Fetch the first value
        cmp     r8,     r6              ; Does the data match?
        beq     %F12                    ; YES - do next test
;
;       No match on 1st value - inform user
;
        mov     r0,     r6      ; copy expected data to r0
        mov     r1,     r4      ; Get address of failed location
        mov     r2,     r8      ; Move actual data to r2
        bl      BBU_MTSP_error  ; Print message

12      ldr     r8,     [r4],   #4      ; Fetch the second value
        cmp     r8,     r7              ; Does the data match?
        beq     %F13                    ; YES - continue      
;
;       No match on 2nd value - inform user
;
        mov     r0,     r7      ; copy expected data to r0
        mov     r1,     r4      ; Get address of failed location
        mov     r2,     r8      ; Move actual data to r2
        bl      BBU_MTSP_error  ; Print message

13      subs    r5,     r5,     #8      ; decrement byte count
        bne     %B11                    ; Loop until done
;
;       Increment current loop counter and exit if equal to max loop count
;
14      ldr     r5,     =BBU_SMTD_CLC   ; Address of current loop counter
        ldr     r6,     [r5]            ; Fetch this value
        ldr     r7,     =BBU_SMTD_LOOP  ; Address of ending loop count
        ldr     r8,     [r7]            ; Fetch this value
        cmp     r6,     r8              ; Are the loop counts equal?
        bne     %F16                    ; No - skip the return
        ldmfd   sp!,    {r0-r12, pc}    ; YES - return to caller
        
16      add     r6,     r6,     #1      ; NO! - Increment current loop count ...
        str     r6,     [r5]            ; ... and save this value       
        b       %B5                     ; Run test again
;
;       Text Messages for CODP memory tests
;
MTS_CODP_MSG1   DCB     "  0x00000004 - Writing Complement Data Pattern - Pass ",0
MTS_CODP_MSG2   DCB     "  0x00000004 - Reading Complement Data Pattern",0xD,0xA,0
        ALIGN   4
        ENDFUNC
;
;*********************************************************************************
;
;       ***************
;       *             * 
;       * bbu_MTS_DDP * Subroutine
;       *             *
;       ***************
;
; This subroutine performs an "Decrement Data Pattern" test on the selected memory

;
; PARAMETER PASSING & REGISTER USE:
;
;       R0 = used for calls to UART subroutines
;       r1 - r8 = available for general use
;       r9  = Starting address of memory test (DO NOT MODIFY!)
;       r10 = Number of bytes to be tested (DO NOT MODIFY!)
;       r11-r12 = available for general use
;       r13 = Stack pointer (sp) - DO NOT MODIFY
;       r14 = Link register (lr) - DO NOT MODIFY
;

bbu_MTS_DDP     FUNCTION

        stmfd   sp!,    {r0-r12, lr}    ; Save r0-r12 and link register on the stack
        ldr     r5,     =BBU_SMTD_CLC   ; Address of current loop counter
        mov     r6,     #1              ; This is pass #1
        str     r6,     [r5]            ; Save this value
        
5       ldr     r0,     =MTS_DDP_MSG1   ; Identify test to be run
        bl      BBU_putstr              ; Send string to user
        mov     r0,     r6              ; Get pass number
        mov     r1,     #0              ; Supress leading zeros
        bl      BBU_UDecToAscii         ; Send to user
        bl      BBU_crlf                ; Output a <CR><LF>
        mov     r4,     r9              ; Set up starting address in r4
        mov     r5,     r10             ; Put byte count into r5
        bic     r5,     r5,     #3      ; Make sure bits 1:0 are clear (4 byte increments)
;
;       See if BBU specified starting pattern is to be used
;
        ldr     r1,     =BBU_SMTD_PAT   ; Address of BBU starting pattern
        ldr     r2,     [r1]            ; Fetch starting pattern
        ldr     r1,     =BBU_SMTD_STAT  ; Address of Memory test status word
        ldr     r3,     [r1]            ; Fetch status word
        ands    r3,     r3,     #1      ; Bit 0 set = Use BBU supplied starting pattern
        movne   r6,     r2              ; Use BBU starting pattern        
        ldreq   r6,     =0xFFFFFFFF     ; Load r6 with test default starting pattern
;
;       Fetch AND mask and OR data word from BBU code
;
        ldr     r1,     =BBU_SMTD_AND   ; Address of AND mask word
        ldr     r2,     [r1]            ; Fetch AND mask
        ldr     r1,     =BBU_SMTD_OR    ; Address of OR data word
        ldr     r3,     [r1]            ; Fetch OR data word
;
;       Fill memory with the test pattern
;
10  ;   and     r7,     r6,     r2      ; AND r6 with AND mask in r2 - COMMENT OUT
    ;   orr     r7,     r7,     r3      ; OR in the data in r3       - COMMENT OUT
        str     r6,     [r4],   #4      ; Store the pattern
        sub     r6,     r6,     #1      ; Decrement pattern value
        subs    r5,     r5,     #4      ; Decrement byte count
        bne     %B10                    ; Loop until memory is filled
;
;       Read pattern back and check for errors
;
        ldr     r0,     =MTS_DDP_MSG2   ; Let user know data is being read
        bl      BBU_putstr              ; Send string to user
;
;       See if BBU specified starting pattern is to be used
;
        ldr     r1,     =BBU_SMTD_PAT   ; Address of BBU starting pattern
        ldr     r2,     [r1]            ; Fetch starting pattern
        ldr     r1,     =BBU_SMTD_STAT  ; Address of Memory test status word
        ldr     r3,     [r1]            ; Fetch status word
        ands    r3,     r3,     #1      ; Bit 0 set = Use BBU supplied starting pattern
        movne   r6,     r2              ; Use BBU starting pattern        
        ldreq   r6,     =0xFFFFFFFF     ; Load r6 with test default starting pattern
        mov     r4,     r9              ; Set up starting address in r4
        mov     r5,     r10             ; Put byte count into r5
        bic     r5,     r5,     #3      ; Make sure bits 1:0 are clear (4 byte increments)

11      ldr     r8,     [r4],   #4      ; Fetch the first value
        cmp     r8,     r6              ; Does the data match?
        beq     %F12                    ; YES - do next test
;
;       No match on value - inform user
;
        mov     r0,     r6      ; copy expected data to r0
        mov     r1,     r4      ; Get address of failed location
        mov     r2,     r8      ; Move actual data to r2
        bl      BBU_MTSP_error  ; Print message
    
12      sub     r6,     r6,     #1      ; Decrement pattern value
        subs    r5,     r5,     #4      ; decrement byte count
        bne     %B11                    ; Loop until done
;
;       Increment current loop counter and exit if equal to max loop count
;
        ldr     r5,     =BBU_SMTD_CLC   ; Address of current loop counter
        ldr     r6,     [r5]            ; Fetch this value
        ldr     r7,     =BBU_SMTD_LOOP  ; Address of ending loop count
        ldr     r8,     [r7]            ; Fetch this value
        cmp     r6,     r8              ; Are the loop counts equal?
        bne     %F13                    ; No - skip the return
        ldmfd   sp!,    {r0-r12, pc}    ; return to caller
        
13      add     r6,     r6,     #1      ; Increment current loop count ...
        str     r6,     [r5]            ; ... and save this value       
        b       %B5                     ; Run test again
;
;       Text Messages for DDP memory tests
;
MTS_DDP_MSG1    DCB     "  0x00000008 - Writing Decrement Data Pattern - Pass ",0
MTS_DDP_MSG2    DCB     "  0x00000008 - Reading Decrement Data Pattern",0xD,0xA,0
        ALIGN   4
        ENDFUNC
;
;*********************************************************************************
;

⌨️ 快捷键说明

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