unsafe_mem.asm contains the memcmp version with the "dubious" memory write. I don't think it would hurt to keep it, since it is not included in stdlib.asm, so it doesn't take up any memory unless manually included. It is also perfectly safe to use in most situations, in which it is about ~0.5 cycles faster per byte than mem.compare.
There are (currently) only two scenarios where the memory write could fail/have unintended side effects:
The end point of the first memory segment overlaps a specific section of its own code
The end point of the first memory segment is within the frame buffer
The primary reason I marked it as "unsafe" is that the side effects in those cases would be rather difficult to trace back to this operation, unless you knew that it temporarily modifies memory.
I did just remember that it has another issue that I planned to fix, but forgot about... Oops
unsafe_mem.asm contains the memcmp version with the "dubious" memory write. I don't think it would hurt to keep it, since it is not included in stdlib.asm, so it doesn't take up any memory unless manually included. It is also perfectly safe to use in *most* situations, in which it is about ~0.5 cycles faster per byte than `mem.compare`.
There are (currently) only two scenarios where the memory write could fail/have unintended side effects:
- The end point of the first memory segment overlaps a specific section of its own code
- The end point of the first memory segment is within the frame buffer
The primary reason I marked it as "unsafe" is that the side effects in those cases would be rather difficult to trace back to this operation, unless you knew that it temporarily modifies memory.
I did just remember that it has another issue that I planned to fix, but forgot about... Oops
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
i think we want to keep actual code outside of stdlib.asm
i propose creating mem.asm
@@ -26,0 +37,4 @@; - `<0` if the first segment is less than the second segment.; - `>0` if the first segment is greater than the second segment.;pub fn_memcmp:I am not sure these functions should be in the main asm file - better make a
memory.asmfile for these.Add `memcmp`, `memcpy`, `memset32`, `unsafe.memcmp`to Add `mem.compare`, `mem.copy`, `mem.fill32`, `unsafe_mem.compare`Do we want to keep unsafe_mem.asm?
unsafe_mem.asm contains the memcmp version with the "dubious" memory write. I don't think it would hurt to keep it, since it is not included in stdlib.asm, so it doesn't take up any memory unless manually included. It is also perfectly safe to use in most situations, in which it is about ~0.5 cycles faster per byte than
mem.compare.There are (currently) only two scenarios where the memory write could fail/have unintended side effects:
The primary reason I marked it as "unsafe" is that the side effects in those cases would be rather difficult to trace back to this operation, unless you knew that it temporarily modifies memory.
I did just remember that it has another issue that I planned to fix, but forgot about... Oops