From 54c734b3bd0daa8b3b9f51d8216b90ed338b2666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Isalski?= Date: Mon, 31 Aug 2026 23:57:55 +0200 Subject: [PATCH] pleegwat's code review fixes --- array.asm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/array.asm b/array.asm index 13dfc4b..0ba4e6b 100644 --- a/array.asm +++ b/array.asm @@ -13,7 +13,6 @@ pub find_index: push r10 ; We will store the stride here push r9 ; We will store the final address 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 r11, r1 @@ -24,6 +23,7 @@ pub find_index: 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 r1 ; We need the array pointer to calculate the item index 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 @@ -47,14 +47,12 @@ pub find_index: ; If we didn't, move to next item add r11, r11, r10 ; We add the stride to the pointer cmp r11, r9 ; We compare with the final address - je find_index_not_found ; If we reached the end we're done - jmp find_index_loop + jne find_index_loop ; If we did not reach the end we jump back into the loop 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 nand r1, zr, zr ; We put -1 in r1 - add sp, sp, 4 ; The old array pointer are not useful jmp find_index_postamble find_index_found_item: