diff options
Diffstat (limited to 'quine.asm')
| -rw-r--r-- | quine.asm | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/quine.asm b/quine.asm index 7d5d9fa..b47eb5a 100644 --- a/quine.asm +++ b/quine.asm @@ -2453,8 +2453,8 @@ cold_start: dq early_here, fetch dq rsi, rdx, mov_reg64_reg64 dq rcx, pop_reg64 - dq rsi, pop_reg64 dq rdi, pop_reg64 + dq rsi, pop_reg64 dq rep_movs8 dq rdx, rsi, mov_reg64_reg64 dq pack_next, lit, 8, packalign, early_here_store @@ -2463,8 +2463,8 @@ cold_start: dq early_here, fetch dq rsi, rdx, mov_reg64_reg64 dq rcx, pop_reg64 - dq rsi, pop_reg64 dq rdi, pop_reg64 + dq rsi, pop_reg64 dq rsi, rax, mov_reg64_reg64 dq rdi, rax, cmp_reg64_reg64 dq lit, 4, cc_below, jmp_cc_rel_imm8 @@ -3025,7 +3025,7 @@ cold_start: 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, 5, 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 @@ -6133,7 +6133,7 @@ cold_start: dq litstring, "lit", early_find, entry_to_execution_token, early_comma dq lit, 10, early_comma dq litstring, "+", early_find, entry_to_execution_token, early_comma - dq litstring, "3unroll", early_find, entry_to_execution_token, early_comma + dq litstring, "swap", early_find, entry_to_execution_token, early_comma dq litstring, "memmove", early_find, entry_to_execution_token, early_comma dq litstring, "here", early_find, entry_to_execution_token, early_comma dq litstring, "@", early_find, entry_to_execution_token, early_comma @@ -8900,8 +8900,8 @@ defword memcopy, 0 ; We need to save and restore rsi; the other registers we can trample. mov.qreg.qreg rdx, rsi pop.qreg rcx - pop.qreg rsi pop.qreg rdi + pop.qreg rsi ; We start from the low end, since that's easier arithmetic. So, we get to ; leave the DF flag alone. rep movsb @@ -8919,8 +8919,8 @@ defword memmove, 0 ; We need to save and restore rsi; the other registers we can trample. mov.qreg.qreg rdx, rsi pop.qreg rcx - pop.qreg rsi pop.qreg rdi + pop.qreg rsi ; We need to check source < destination to decide which end to start from. mov.qreg.qreg rax, rsi @@ -9532,10 +9532,10 @@ defword packstring, 0 dq docol dq dup, stringlen, lit, 1, add, dup ; base/destination, source, length, length - dq lit, 4, roll, dup, lit, 5, unroll - ; destination, source, length, length, base/destination + dq lit, 4, roll, dup, lit, 4, unroll + ; source, destination, length, length, base/destination dq add, lit, 4, unroll - ; new base, destination, source, length + ; new base, source, destination, length dq memcopy dq exit @@ -11710,7 +11710,7 @@ defword self_raw, 0 ; destination destination source length dq dup, lit, 4, roll, add, lit, 4, unroll ; result destination source length - dq memcopy + dq memcopy ; broken since memcopy args change dq exit @@ -11829,8 +11829,7 @@ defword boot_source, 0x40 dq ": } dup here @ swap - ; make-immediate " ; (start pointer, length) - dq ": if 2dup swap dup 5 8 * + 3unroll swap " - ; ~ TODO this is wrong, it goes adjusted start, start, length? probably? + dq ": if 2dup swap dup 5 8 * + 3roll " ; (start pointer, length, start pointer, adjusted start pointer, length) dq " memmove " ; (start pointer, length) @@ -11845,7 +11844,7 @@ defword boot_source, 0x40 dq " drop 5 8 * + here ! ; make-immediate " ; (start pointer, length) - dq ": unless 2dup swap dup 5 8 * + 3unroll swap " + dq ": unless 2dup swap dup 5 8 * + 3roll " ; (start pointer, length, start pointer, adjusted start pointer, length) dq " memmove " ; (start pointer, length) @@ -11869,9 +11868,13 @@ defword boot_source, 0x40 ; Those spaces will take five words, and two words, respectively. So the ; false-block gets moved by seven words, and the true-block gets moved by ; five words. - dq " 2dup swap dup 7 8 * + swap 3roll memmove " + ; + ; Note that this has diverged slightly from the self-hosted version, + ; because in this version we don't have "pick" yet. + dq " 2dup swap dup 7 8 * + 3roll memmove " dq " 4 roll dup 5 unroll 4 roll dup 5 unroll " - dq " swap dup 5 8 * + swap 3roll memmove " + dq " swap dup 5 8 * + 3roll memmove " + ; (true start, true length, false start, false length) ; ; Now we write out the initial test-and-branch. @@ -11906,7 +11909,7 @@ defword boot_source, 0x40 ; (test start, test length, body start, body length) dq ": while " ; The conditional branch needs five words. - dq " 2dup swap dup 5 8 * + swap 3roll memmove " + dq " 2dup swap dup 5 8 * + 3roll memmove " dq " here @ 5 unroll swap dup 3unroll here ! " ; (old here, test start, test length, body start, body length) dq " ' lit entry-to-execution-token , 0 , " |