From cc4756494a7f799219433124a57d06687a4c0091 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 13 Apr 2026 17:57:50 -0700 Subject: fix more Forth-assembly words the words that needed fixes were unroll, stringlen, 0branch, and sys-exit this is now everything that's expected to agree, we're pretty sure the disassemblies of litpack* contain absolute addresses of the corresponding pack* words, so those are expected to be different, and the differences look correct at the byte level similarly, the implementation of docol is significantly different structurally and that's also expected Force-Push: yes Change-Id: I0028fb00b4ce51a7f7c608a3153323cf4a2e5a25 --- quine.asm | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/quine.asm b/quine.asm index e0d5205..ab4cdd0 100644 --- a/quine.asm +++ b/quine.asm @@ -2106,11 +2106,12 @@ cold_start: dq rcx, pop_reg64 dq rcx, dec_reg64 dq rcx, rdx, mov_reg64_reg64 - dq rsp, rbp, mov_reg64_indirect_reg64 + dq rsp, rbx, mov_reg64_indirect_reg64 dq rsi, push_reg64 dq rsp, lit, 16, rsi, lea_reg64_disp8_reg64 dq rsp, lit, 8, rdi, lea_reg64_disp8_reg64 dq rep_movs64 + dq rsi, pop_reg64 dq rbx, rsp, rdx, lit, 8, mov_indexed_reg64_reg64 dq pack_next, lit, 8, packalign, early_here_store @@ -2458,6 +2459,7 @@ cold_start: dq rcx, not_reg64 dq repnz_scas8 dq rbx, rdi, sub_reg64_reg64 + dq lit, 1, rdi, sub_reg64_imm8 dq rdi, push_reg64 dq pack_next, lit, 8, packalign, early_here_store @@ -2528,9 +2530,10 @@ cold_start: dq rax, pop_reg64 dq rax, rax, test_reg64_reg64 ; Retrieve the saved address for the start of "branch". Compute the - ; relative offset from the current address to it. Add two bytes to allow - ; for the length of the jmp instruction. - dq dup, lit, 4, roll, sub, lit, 2, add + ; relative offset from the current address to it. This will be a negative + ; number. Subtract an additional two bytes, to allow for the length of the + ; jmp instruction. + dq dup, lit, 4, roll, swap, sub, lit, 2, sub ; It's slightly counterintuitive that the condition is called cc_equal; ; that's a result of the condition names favoring cmp over test. While cmp ; simulates subtraction, test simulates bitwise AND. What we're testing is @@ -2555,7 +2558,9 @@ cold_start: dq rdi, pop_reg64 dq syscall dq hlt - dq pack_next, lit, 8, packalign, early_here_store + ; This one, uniquely, doesn't need to be followed by the "next" macro. It + ; still needs alignment padding though. + dq lit, 8, packalign, early_here_store ; This was "sys_write". dq litstring, "sys-write", early_create, early_self_codeword -- cgit 1.4.1