I'm having issues with my code, I'm trying to find the max value in an array but my logic isn't working. Any ideas?
; Parameter 1: RDI -- address of array (pass by reference)
; Parameter 2: RSI -- array size        (pass by value)
; Parameter 3: RDX -- maximum of an array (pass by reference)
; Register usage: RAX -- temporary maximum value
; RBX -- address of array for “register indirect memory addressing”
; RCX -- counter for “loop” instruction
findMax:
        push rbx                ; save registers
        mov rdi, 0              ; address of array (Parameter 1)-input (reference)
        mov rsi, 0              ; array size (Parameter 2)-input (value)
        mov [temp-max],ar[0]    ; initialize max (temp-max) to array[0]
myLoop:
        cmp rbx, [temp-max]     ; compare array element to temp-max
        jle next                ; jump if not greater
        mov rbx, rdx            ; new max found, update temp-max
next:   add rbx, 8              ; get address of next array element
        loop myLoop             ; repeat
        mov rdx,[temp-max]      ; store max in memory(Parameter 3)- output(reference)
        pop rbx                 ; restore registers
        ret                     ; return
 
    