diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-05-28 21:07:55 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-05-28 21:07:55 -0700 |
| commit | 0f3c90d8c67c7150feed36a1e620a6aa68f987a7 (patch) | |
| tree | bc80e407fd8508afdd78f99e8dae5e958a454622 /quine.asm | |
| parent | fb57c4ae52e9836f52e4fc5d4999824ebdd2c57c (diff) | |
moved pack-raw-string into core.e
Force-Push: yes Change-Id: I0940c0c21580e810716a5f61b95fd520c464ab9e
Diffstat (limited to 'quine.asm')
| -rw-r--r-- | quine.asm | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/quine.asm b/quine.asm index b47eb5a..3002cab 100644 --- a/quine.asm +++ b/quine.asm @@ -3035,6 +3035,26 @@ cold_start: dq litstring, "exit", early_find, entry_to_execution_token, early_comma dq early_here, fetch, lit, 8, packalign, early_here_store + ; This was "pack_raw_string". + dq litstring, "pack-raw-string", early_create, early_docol_codeword + dq litstring, "dup", early_find, entry_to_execution_token, early_comma + dq litstring, "stringlen", early_find, entry_to_execution_token, early_comma + dq litstring, "dup", early_find, entry_to_execution_token, early_comma + dq litstring, "lit", early_find, entry_to_execution_token, early_comma + dq lit, 4, early_comma + dq litstring, "roll", early_find, entry_to_execution_token, early_comma + dq litstring, "dup", early_find, entry_to_execution_token, early_comma + dq litstring, "lit", early_find, entry_to_execution_token, early_comma + dq lit, 4, early_comma + dq litstring, "unroll", early_find, entry_to_execution_token, early_comma + dq litstring, "+", early_find, entry_to_execution_token, early_comma + dq litstring, "lit", early_find, entry_to_execution_token, early_comma + dq lit, 4, early_comma + dq litstring, "unroll", early_find, entry_to_execution_token, early_comma + dq litstring, "memcopy", early_find, entry_to_execution_token, early_comma + dq litstring, "exit", early_find, entry_to_execution_token, early_comma + dq early_here, fetch, lit, 8, packalign, early_here_store + dq litstring, "packalign", early_create, early_docol_codeword dq litstring, "2dup", early_find, entry_to_execution_token, early_comma dq litstring, "/%", early_find, entry_to_execution_token, early_comma @@ -9539,6 +9559,24 @@ defword packstring, 0 dq memcopy dq exit +; This also works on C-style strings, relying on the null terminator, but +; the packed data does not include it. +; +; Stack in: +; base address, string pointer +; Stack out: +; new base address +defword pack_raw_string, 0 + dq docol + dq dup, stringlen, dup + ; base/destination, source, length, length + dq lit, 4, roll, dup, lit, 4, unroll + ; source, destination, length, length, base/destination + dq add, lit, 4, unroll + ; new base, source, destination, length + dq memcopy + dq exit + ; Stack in: ; base address ; byte size |