Handle empty case for memcpy_bytes

This commit is contained in:
Robin Salen 2023-10-23 19:12:54 -04:00
parent 8af189b927
commit 83054b0ffe
No known key found for this signature in database
GPG Key ID: FB87BACFB3CB2007

View File

@ -57,6 +57,17 @@ memcpy_finish:
// Similar logic to memcpy, but optimized for copying sequences of bytes.
global memcpy_bytes:
// stack: DST, SRC, count, retdest
// Handle empty case
DUP7
// stack: count, DST, SRC, count, retdest
ISZERO
// stack: count == 0, DST, SRC, count, retdest
%jumpi(memcpy_bytes_empty)
// stack: DST, SRC, count, retdest
// Handle small case
DUP7
// stack: count, DST, SRC, count, retdest
%lt_const(0x20)
@ -119,6 +130,12 @@ memcpy_bytes_finish:
// stack: retdest
JUMP
memcpy_bytes_empty:
// stack: DST, SRC, count, retdest
%pop7
// stack: retdest
JUMP
%macro memcpy_bytes
%stack (dst: 3, src: 3, count) -> (dst, src, count, %%after)
%jump(memcpy_bytes)