From 3b00a5376036bb3f50a1a1f97d136305a2d03a57 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Thu, 28 May 2026 19:34:07 -0700 Subject: change the parameter order for memcopy and memmove that was surprisingly involved, but it feels like the right thing to do Change-Id: Ia2f38c7278f4237cebd0435d27131fe32dbc3718 Force-Push: yes --- core.e | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'core.e') diff --git a/core.e b/core.e index a636c07..62e2301 100644 --- a/core.e +++ b/core.e @@ -757,15 +757,14 @@ here ! ~ Jonesforth also offers C@C! as another name for its CCOPY, but neither ~ "@!" nor "mem@mem!" seems particulaly nice. ~ -~ TODO these parameters feel backwards -~ (destination, source, length --) +~ (source, destination, length --) : memcopy [ here @ ~ We need to save and restore rsi; the other registers we can trample. :rsi :rdx mov-reg64-reg64 :rcx pop-reg64 - :rsi pop-reg64 :rdi pop-reg64 + :rsi pop-reg64 ~ We start from the low end, since that's easier arithmetic. So, we get ~ to leave the DF flag alone. rep-movs8 @@ -777,15 +776,14 @@ here ! ~ careful about which end the transfer starts from. This "move" vs. "copy" ~ distinction mirrors C terminology. ~ -~ TODO these parameters feel backwards -~ (destination, source, length --) +~ (source, destination, length --) : memmove [ here @ ~ We need to save and restore rsi; the other registers we can trample. :rsi :rdx mov-reg64-reg64 :rcx pop-reg64 - :rsi pop-reg64 :rdi pop-reg64 + :rsi pop-reg64 ~ We need to check source < destination to decide which end to start from. :rsi :rax mov-reg64-reg64 @@ -1192,10 +1190,11 @@ here ! : packstring dup stringlen 1 + dup ~ (output point, source, length, length) - 4 roll dup 5 unroll - ~ (destination, source, length, length, output point) + 4 roll dup 4 unroll + + ~ (source, destination, length, length, output point) + 4 unroll - ~ (output point, destination, source, length) + ~ (output point, source, destination, length) memcopy ; ~ (output point, alignment byte count -- output point) -- cgit 1.4.1