From f09521fd6d5d7d3a4e03f17e87be8efb371165d8 Mon Sep 17 00:00:00 2001 From: Perry Kivolowitz Date: Fri, 17 Feb 2023 09:27:32 -0600 Subject: [PATCH] correct min and max based on nudge from u\TNorthover --- macros/apple-linux-convergence.S | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/macros/apple-linux-convergence.S b/macros/apple-linux-convergence.S index 8d283a7..f804854 100644 --- a/macros/apple-linux-convergence.S +++ b/macros/apple-linux-convergence.S @@ -119,10 +119,28 @@ main: ldr \a, [sp], 16 .endm -.macro MIN src_a, src_b, dest - csel \dest, \src_a, \src_b, GT -.endm +/* The smaller of src_a and src_b is put into dest. A cmp instruction + or other instruction that sets the flags must be performed first. + This macro makes it easy to remember which register does what in the + csel. + + Thank you to u/TNorthover for nudge to add the cmp. +*/ -.macro MAX src_a, src_b, dest +.macro MIN src_a, src_b, dest + cmp \src_a, \src_b csel \dest, \src_a, \src_b, LT .endm + +/* The larger of src_a and src_b is put into dest. A cmp instruction + or other instruction that sets the flags must be performed first. + This macro makes it easy to remember which register does what in the + csel. + + Thank you to u/TNorthover for nudge to add the cmp. +*/ + +.macro MAX src_a, src_b, dest + cmp \src_a, \src_b + csel \dest, \src_a, \src_b, GT +.endm