Added find_index array function
#9
@@ -13,7 +13,6 @@ pub find_index:
|
|||||||
push r10 ; We will store the stride here
|
push r10 ; We will store the stride here
|
||||||
push r9 ; We will store the final address here
|
push r9 ; We will store the final address here
|
||||||
push r8 ; We will store the mask here
|
push r8 ; We will store the mask here
|
||||||
push r1 ; We need the array pointer to calculate the item index
|
|
||||||
|
|
||||||
mov r12, r4
|
mov r12, r4
|
||||||
mov r11, r1
|
mov r11, r1
|
||||||
@@ -24,6 +23,7 @@ pub find_index:
|
|||||||
add r9, r9, r1 ; We add the start address to get the final address
|
add r9, r9, r1 ; We add the start address to get the final address
|
||||||
|
|
||||||
push r13 ; We save up the return address because we will provide our own to the predicate
|
push r13 ; We save up the return address because we will provide our own to the predicate
|
||||||
|
push r1 ; We need the array pointer to calculate the item index
|
||||||
counter r13
|
counter r13
|
||||||
add r13, r13, 52 ; Point to just after the predicate call - we can set this up now so we don't waste loop cycles
|
add r13, r13, 52 ; Point to just after the predicate call - we can set this up now so we don't waste loop cycles
|
||||||
|
|
||||||
@@ -47,14 +47,12 @@ pub find_index:
|
|||||||
; If we didn't, move to next item
|
; If we didn't, move to next item
|
||||||
add r11, r11, r10 ; We add the stride to the pointer
|
add r11, r11, r10 ; We add the stride to the pointer
|
||||||
cmp r11, r9 ; We compare with the final address
|
cmp r11, r9 ; We compare with the final address
|
||||||
je find_index_not_found ; If we reached the end we're done
|
jne find_index_loop ; If we did not reach the end we jump back into the loop
|
||||||
jmp find_index_loop
|
|
||||||
|
|
||||||
find_index_not_found:
|
find_index_not_found:
|
||||||
add sp, sp, 4 ; The predicate context is not useful
|
add sp, sp, 8 ; The predicate context and old array pointer are not useful
|
||||||
pop r13 ; We get our return address
|
pop r13 ; We get our return address
|
||||||
nand r1, zr, zr ; We put -1 in r1
|
nand r1, zr, zr ; We put -1 in r1
|
||||||
add sp, sp, 4 ; The old array pointer are not useful
|
|
||||||
jmp find_index_postamble
|
jmp find_index_postamble
|
||||||
|
|
||||||
find_index_found_item:
|
find_index_found_item:
|
||||||
|
|||||||
Reference in New Issue
Block a user