Also for memset

This commit is contained in:
Robin Salen 2023-10-23 19:40:32 -04:00
parent 83054b0ffe
commit 60811d083f
No known key found for this signature in database
GPG Key ID: FB87BACFB3CB2007
2 changed files with 17 additions and 1 deletions

View File

@ -131,7 +131,7 @@ memcpy_bytes_finish:
JUMP
memcpy_bytes_empty:
// stack: DST, SRC, count, retdest
// stack: DST, SRC, 0, retdest
%pop7
// stack: retdest
JUMP

View File

@ -2,12 +2,22 @@
// DST = (dst_ctx, dst_segment, dst_addr).
// This tuple definition is used for brevity in the stack comments below.
global memset:
// Handle empty case
DUP7
// stack: count, DST, count, retdest
ISZERO
// stack: count == 0, DST, count, retdest
%jumpi(memset_bytes_empty)
// stack: DST, count, retdest
// Handle small case
DUP4
// stack: count, DST, count, retdest
%lt_const(0x20)
// stack: count < 32, DST, count, retdest
%jumpi(memset_finish)
// stack: DST, count, retdest
PUSH 32
PUSH 0
@ -43,3 +53,9 @@ memset_finish:
%pop4
// stack: retdest
JUMP
memset_bytes_empty:
// stack: DST, 0, retdest
%pop4
// stack: retdest
JUMP