// looper.s -
// Expects:
//      x0: long int *array
//      x1: long int length
// Returns:
//      x0: long int answer
.equ FrameSize, 16
    .text
    .global looper
looper:
    stp  x29, x30, [sp, -FrameSize] !   // set up frame
    mov  x29, sp                        // set fp

    ldr  x9, [x0]       // start w/ 1st value
    mov  x2, 1          // loop counter
    b    check
each:
    ldr  x3, [x0, x2, lsl #3]   // get each array element
    cmp  x3, x9
    b.le next
    mov  x9, x3
next:
    add  x2, x2, 1      // increment loop counter
check:
    cmp  x2, x1
    b.lo each
done:
    mov  x0, x9
    mov  sp, x29                        // restore sp
    ldp  x29, x30, [sp], FrameSize      // tear down frame
    ret
#--------