summary refs log tree commit diff
path: root/quine.asm
diff options
context:
space:
mode:
Diffstat (limited to 'quine.asm')
-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