forked from TCShenanigans/symphony_stdlib
Tested and fixed stride->shift conversion missing
This commit is contained in:
@@ -19,7 +19,8 @@ pub find_index:
|
|||||||
mov r11, r1
|
mov r11, r1
|
||||||
mov r10, r3
|
mov r10, r3
|
||||||
mov r9, r2
|
mov r9, r2
|
||||||
lsl r9, r9, r3 ; We calculate bytes left
|
lsr r6, r3, 1 ; We turn the stride into a byte shift
|
||||||
|
lsl r9, r9, r6 ; We calculate bytes left
|
||||||
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
|
||||||
@@ -42,11 +43,11 @@ pub find_index:
|
|||||||
load_32 r2, [sp] ; We load the predicate context into r2
|
load_32 r2, [sp] ; We load the predicate context into r2
|
||||||
jmp r12 ; We call the predicate
|
jmp r12 ; We call the predicate
|
||||||
cmp r1, zr
|
cmp r1, zr
|
||||||
jneq find_index_found_item ; If we found the item, we jump out
|
jne find_index_found_item ; If we found the item, we jump out
|
||||||
; 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
|
||||||
jeq find_index_not_found ; If we reached the end we're done
|
je find_index_not_found ; If we reached the end we're done
|
||||||
jmp find_index_loop
|
jmp find_index_loop
|
||||||
|
|
||||||
find_index_not_found:
|
find_index_not_found:
|
||||||
@@ -71,4 +72,3 @@ pub find_index:
|
|||||||
pop r11
|
pop r11
|
||||||
pop r12
|
pop r12
|
||||||
jmp r13 ; Return
|
jmp r13 ; Return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user