summary refs log tree commit diff
path: root/quine.asm
diff options
context:
space:
mode:
Diffstat (limited to 'quine.asm')
-rw-r--r--quine.asm84
1 files changed, 58 insertions, 26 deletions
diff --git a/quine.asm b/quine.asm
index b8b65fe..c92f1cd 100644
--- a/quine.asm
+++ b/quine.asm
@@ -2233,23 +2233,31 @@ cold_start:
   ; This is "store", but since we're finally in Forth we're no longer limited
   ; by flatassembler's syntax, so we call it by its usual Forth name.
   dq litstring, "!", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, pop_reg64
+  dq rax, rbx, mov_indirect_reg64_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This is "fetch".
   dq litstring, "@", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rax, pop_reg64
+  dq rax, rax, mov_reg64_indirect_reg64
+  dq rax, push_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This is "addstore".
   dq litstring, "+!", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, pop_reg64
+  dq rax, rbx, add_indirect_reg64_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This is "substore".
   dq litstring, "-!", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, pop_reg64
+  dq rax, rbx, sub_indirect_reg64_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This was "store8". Jonesforth calls it "c!" but we categorically reject
   ; the use of letters that are meant to indicate byte sizes. It's unfriendly
@@ -2257,44 +2265,67 @@ cold_start:
   ; meaning "store a value of 8", but that would not be a useful task, so
   ; hopefully it'll be okay.
   dq litstring, "8!", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, pop_reg64
+  dq al, rbx, mov_indirect_reg64_reg8
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This was "fetch8".
   dq litstring, "8@", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, rax, xor_reg64_reg64
+  dq rbx, al, mov_reg8_indirect_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This was "store16".
   dq litstring, "16!", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, pop_reg64
+  dq ax, rbx, mov_indirect_reg64_reg16
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This was "fetch16".
   dq litstring, "16@", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, rax, xor_reg64_reg64
+  dq rbx, ax, mov_reg16_indirect_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This was "store32".
   dq litstring, "32!", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, pop_reg64
+  dq eax, rbx, mov_indirect_reg64_reg32
+  dq pack_next, lit, 8, packalign, early_here_store
 
   ; This was "fetch32".
   dq litstring, "32@", early_create, early_self_codeword, early_here, fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rbx, pop_reg64
+  dq rax, rax, xor_reg64_reg64
+  dq rbx, eax, mov_reg32_indirect_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   dq litstring, "memcopy", early_create, early_self_codeword, early_here
   dq fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rsi, rdx, mov_reg64_reg64
+  dq rcx, pop_reg64
+  dq rsi, pop_reg64
+  dq rdi, pop_reg64
+  dq rep_movs8
+  dq rdx, rsi, mov_reg64_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
-  ; TODO why does this crash?
   dq litstring, "stringlen", early_create, early_self_codeword, early_here
   dq fetch
-  ; TODO
-  dq lit, 8, packalign, early_here_store
+  dq rdi, pop_reg64
+  dq rdi, rbx, mov_reg64_reg64
+  dq rax, rax, xor_reg64_reg64
+  dq rcx, rcx, xor_reg64_reg64
+  dq rcx, not_reg64
+  dq repnz_scas8
+  dq rbx, rdi, sub_reg64_reg64
+  dq rdi, push_reg64
+  dq pack_next, lit, 8, packalign, early_here_store
 
   dq litstring, "branch", early_create, early_self_codeword, early_here, fetch
   ; TODO
@@ -3907,7 +3938,7 @@ defword mov_disp8_reg64_reg8, 0
 ;   target register name
 defword mov_reg8_indirect_reg64, 0
   dq docol
-  dq roll3, pack8, lit, 0x8A, pack8, unroll3
+  dq roll3, lit, 0x8A, pack8, unroll3
   dq reg8, swap, addressing_indirect_reg64
   dq exit
 
@@ -4064,6 +4095,7 @@ defword sub_indirect_reg64_reg64, 0
   dq docol
   dq roll3, rex_w, lit, 0x2B, pack8, unroll3
   dq swap, reg64, swap, addressing_indirect_reg64
+  dq exit
 
 ;   The target register is always rax.
 ;