From a2420be4c8876bad6f0715849d8a7cb1f4eec43b Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Tue, 30 Apr 2019 17:59:03 +0200 Subject: [PATCH] Optimize for special cases --- ucode/sort4.uc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ucode/sort4.uc b/ucode/sort4.uc index 1efecf8..151c906 100644 --- a/ucode/sort4.uc +++ b/ucode/sort4.uc @@ -224,15 +224,16 @@ sub gr; incpc // Increment bucket length mov pc pm; bls @IE_SPEC // Store new length mov ar pc; sub ar -sub ir +sub ir // Save -IR into AR (you'll see why) + $INSERTION mov pc asr; incpc; declc; bls @INSERTION_END_BIGGEST -add pm +add pm // Effectively, AR=PM-IR, except more like AR=-IR+PM sub pm; brn @INSERTION mov pm ar -mov ir pm +mov ir pm; bls @IEN_SPEC $INSERTION_SHIFT mov pc asr @@ -240,6 +241,10 @@ mov pm ir mov ar pm; bls @INSERTION_END_NOTBIGGEST mov ir ar; declc; incpc; bra @INSERTION_SHIFT +$IEN_SPEC +mov pc asr +mov ar pm; bra @INSERTION_END_NOTBIGGEST + $IE_SPEC mov ar asr