Arm汇编求数组最大值和最小值

求数组最大值和最小值

    AREA text,CODE,READONLY
        code32
        entry
start                                       ;/* code start */
        ldr     r0,=array                   ;r0 point to the 100 array
        mov     r2, #1
arrayinit
        str     r2, [r0], #4
        add     r2, r2, #1
        cmp     r2, #101
        bne     arrayinit
maxmininit
        ldr     r0,=array
        ldr     r2, [r0]                ;r2 point to the max
        ldr     r3, [r0]                ;r3 point to the min
        mov     r1, #1
maxmin
        ldr     r4, [r0], #4
        cmp     r2, r4
        movcc   r2, r4
        cmp     r3, r4
        movcs   r3, r4
        add     r1, r1, #1
        cmp     r1, #101
        bne     maxmin
stop                                    
        b       stop

        ltorg
array   space   100
        end

你可能感兴趣的:(嵌入式)