diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-05-28 19:34:07 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-05-28 20:28:48 -0700 |
| commit | 3b00a5376036bb3f50a1a1f97d136305a2d03a57 (patch) | |
| tree | c08ec1927761909aa76981d9eb964725e00ddc72 /core.e | |
| parent | d9a82e9f3c87aa318fb05819249656b43fde15e3 (diff) | |
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
Diffstat (limited to 'core.e')
| -rw-r--r-- | core.e | 17 |
1 files changed, 8 insertions, 9 deletions
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) |