AArch64, loop for finding maximum lazarus / 21-General ---------------------------------------------------------------------- LemonParty · 2025-06-28 11:18 Hello. I write a simple function for finding maximum in an array using AArch64 assembler. It doesn't work. I think an error is in loop. The loop: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   ...  mov x3,Range  lsr x3,x3,#2  cbz x3,.LShortIn.LP1: //loop for processing 4 bytes  ldr s1,[x0],#4 //load 4 bytes from buffer and increment pointer  umax v0.16b,v0.16b,v1.16b //collect maximums to v0  subs x3,x3,#1 //decrease counter  sub Range,Range,#4 //decrease global counter  b.ne .LP1  ... Why this code may not work? ---------------------------------------------------------------------- Thaddy · 2025-06-28 12:31 Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   umax v0.16b,v0.16b,v1.16bThese are 128 instructions, not 32 , like you indicate by using ldr S1 (which is 32 ). Try v0.4s and v1.4s which makes it 32. Not tested yet, but will do that later on one of my RPi's or the mac. I think the actual error is a mismatch in instruction size. Note I do not venture too much is AARCH64 assembler because to me the compiler does a good job. ---------------------------------------------------------------------- LemonParty · 2025-06-28 12:47 I search in a buffer of bytes maximum byte value, so Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i umax v0.16b,v0.16b,v1.16bis correct. I use v0 higher in my code to accumulate maximums from 32 byte chunks. ---------------------------------------------------------------------- Thaddy · 2025-06-28 13:12 No! you use ldr s1,[x0],#4 which is 32. Look again. How is that supposed to work?.......... ---------------------------------------------------------------------- LemonParty · 2025-06-28 13:40 I found the problem. It was in different place. QuoteNo! you use ldr s1,[x0],#4 which is 32. That is right, insted of using ldrb and load single byte, I use s1, which load 4 bytes per time. This 4 bytes is a lower part of v1 and in last stage we collect maximums to v0. I am interesting when ldr s1,[x0],#4 execute what happening to the higher part of register v1? Is it left unchanged or it zeroed? ---------------------------------------------------------------------- LemonParty · 2025-06-28 18:18 QuoteI am interesting when ldr s1,[x0],#4 execute what happening to the higher part of register v1?Zeroed.