summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-04-13 17:57:50 -0700
committerIrene Knapp <ireneista@irenes.space>2026-04-13 17:59:54 -0700
commitcc4756494a7f799219433124a57d06687a4c0091 (patch)
tree81d87515e16dd78d0a0384c19a54ad1d3b00f4e9
parent1a6a056697f50cf2c9a46bc376caa8e198e88031 (diff)
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
-rw-r--r--quine.asm15
1 files 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