diff options
| -rw-r--r-- | README.txt | 2 | ||||
| -rw-r--r-- | hex.hex | 72 | ||||
| -rw-r--r-- | quine.asm | 2 | ||||
| -rw-r--r-- | transform.e | 2 |
4 files changed, 41 insertions, 37 deletions
diff --git a/README.txt b/README.txt index 1e1094d..f2c52f0 100644 --- a/README.txt +++ b/README.txt @@ -296,7 +296,7 @@ written in Evocation-assembly), if you intend to play around with this you may wish to know how to attempt to run it on things. The latest draft way to do that is: - $ (cat labels.e elf.e transform.e; echo 's" xyzzy" allocate-string dup 1048576 read-to-buffer'; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e labels.e elf.e transform.e execution.e; echo 's" pyrzqxgl" allocate-string dup 262144 read-to-buffer '; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl swap 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e; echo pyrzqxgl; cat evoke.e; echo 'xyzzy s" evoke-source" variable 1024 1024 2 * * allocate s" evoke-binary" variable 1024 1024 * allocate s" evoke-metadata" variable evoke-metadata evoke-binary dup evoke-source 5 roll hex-transform bye ' ) | ./evoke > evoke.hex + $ (cat labels.e elf.e transform.e; echo 's" xyzzy" allocate-string dup 1048576 read-to-buffer'; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e labels.e elf.e transform.e execution.e; echo 's" pyrzqxgl" allocate-string dup 262144 read-to-buffer '; cat core.e linux.e output.e amd64.e execution-support.e log-load.e; echo pyrzqxgl swap 262144 read-to-buffer; cat core.e linux.e output.e amd64.e execution-support.e log-load.e dynamic.e input.e interpret.e flow-control.e linux-dynamic.e; echo pyrzqxgl; cat evoke.e; echo 'xyzzy s" evoke-source" variable 1024 1024 2 * * allocate s" evoke-binary" variable 1024 1024 2 * * allocate s" evoke-metadata" variable evoke-metadata evoke-binary dup evoke-source 5 roll hex-transform bye ' ) | ./evoke > evoke.hex It should run to completion, producing output. The output is even correct in the sense that passing evoke.hex through ./hex will give a binary that's diff --git a/hex.hex b/hex.hex index 1c30eae..28a5ed2 100644 --- a/hex.hex +++ b/hex.hex @@ -54,14 +54,14 @@ ~ and keep it there. We've made sure our load origin fits in 32 bits, so ~ we can use imm32 for that. We're going to want to do an indirect load ~ from it, so we can't use rbp for this. - 48 c7 c3 d8 01 00 08 ~ 0x080001d8 :rbx mov-reg64-imm32 + 48 c7 c3 d8 01 00 08 ~ 0x80001d8 :rbx mov-reg64-imm32 - e8 88 00 00 00 ~ 0x00000088 call-rel-imm32 + e8 88 00 00 00 ~ 0x88 call-rel-imm32 ~ If the length is 0, we got EOF. If it's less than zero, we got a read ~ error. Either way, we exit. This is a signed comparison, as it needs to ~ be. - 48 83 f8 00 ~ 0x00 :rax cmp-reg64-imm8 + 48 83 f8 00 ~ 0x0 :rax cmp-reg64-imm8 74 72 ~ 0x72 :cc-equal jmp-cc-rel-imm8 7c ee ~ 0xee :cc-less jmp-cc-rel-imm8 @@ -72,7 +72,7 @@ 48 83 f8 20 ~ 0x20 :rax cmp-reg64-imm8 ~ ASCII space 74 ea ~ 0xffffffffffffffea :cc-equal jmp-cc-rel-imm8 - 48 83 f8 0a ~ 0x0a :rax cmp-reg64-imm8 + 48 83 f8 0a ~ 0xa :rax cmp-reg64-imm8 ~ ASCII linefeed 74 e4 ~ 0xffffffffffffffe4 :cc-equal jmp-cc-rel-imm8 ~ If it's a comment, skip the whole thing. @@ -81,17 +81,17 @@ 74 43 ~ 0x43 :cc-equal jmp-cc-rel-imm8 ~ Decode the value, or exit with an error. - e8 79 00 00 00 ~ 0x00000079 call-rel-imm32 + e8 79 00 00 00 ~ 0x79 call-rel-imm32 ~ We use rbp as a place to stash the high nibble. 48 89 c5 ~ :rax :rbp mov-reg64-reg64 - 48 c1 c5 04 ~ 0x04 :rbp rol-reg64-imm8 + 48 c1 c5 04 ~ 0x4 :rbp rol-reg64-imm8 ~ Now we read another byte. - e8 5a 00 00 00 ~ 0x0000005a call-rel-imm32 + e8 5a 00 00 00 ~ 0x5a call-rel-imm32 ~ Handle the length. A second hex digit is required here. - 48 83 f8 00 ~ 0x00 :rax cmp-reg64-imm8 + 48 83 f8 00 ~ 0x0 :rax cmp-reg64-imm8 74 ac ~ 0xac :cc-equal jmp-cc-rel-imm8 7c c0 ~ 0xc0 :cc-less jmp-cc-rel-imm8 @@ -99,20 +99,20 @@ 48 8b 03 ~ :rbx :rax mov-reg64-indirect-reg64 ~ Decode the value, or exit with an error. - e8 5d 00 00 00 ~ 0x0000005d call-rel-imm32 + e8 5d 00 00 00 ~ 0x5d call-rel-imm32 ~ We OR in the low nibble. 48 0b e8 ~ :rax :rbp or-reg64-reg64 ~ Output the byte. We reuse the buffer as a place to store it. - 48 89 2b ~ :rbx :rbp mov-indirect-reg64-reg64 + 48 89 2b ~ :rbp :rbx mov-indirect-reg64-reg64 48 89 de ~ :rbx :rsi mov-reg64-reg64 ~ buffer pointer - 48 c7 c2 01 00 00 00 ~ 0x00000001 :rdx mov-reg64-imm32 + 48 c7 c2 01 00 00 00 ~ 0x1 :rdx mov-reg64-imm32 ~ buffer length - 48 c7 c0 01 00 00 00 ~ 0x00000001 :rax mov-reg64-imm32 + 48 c7 c0 01 00 00 00 ~ 0x1 :rax mov-reg64-imm32 ~ syscall number for sys-write - 48 c7 c7 01 00 00 00 ~ 0x00000001 :rdi mov-reg64-imm32 + 48 c7 c7 01 00 00 00 ~ 0x1 :rdi mov-reg64-imm32 ~ file descriptor 1 is stdout 0f 05 ~ syscall @@ -120,18 +120,18 @@ eb 9b ~ 0xffffffffffffff9b jmp-rel-imm8 ~ Read a byte for the comment. - e8 23 00 00 00 ~ 0x00000023 call-rel-imm32 + e8 23 00 00 00 ~ 0x23 call-rel-imm32 ~ Handle the length. We're allowed to end in a comment. - 48 83 f8 00 ~ 0x00 :rax cmp-reg64-imm8 - 74 0d ~ 0x0d :cc-equal jmp-cc-rel-imm8 + 48 83 f8 00 ~ 0x0 :rax cmp-reg64-imm8 + 74 0d ~ 0xd :cc-equal jmp-cc-rel-imm8 7c 89 ~ 0x89 :cc-less jmp-cc-rel-imm8 ~ Now that the length is handled, retrieve the input byte. 48 8b 03 ~ :rbx :rax mov-reg64-indirect-reg64 ~ If it's linefeed, the comment is over. - 48 83 f8 0a ~ 0x0a :rax cmp-reg64-imm8 + 48 83 f8 0a ~ 0xa :rax cmp-reg64-imm8 ~ ASCII linefeed 74 85 ~ 0xffffffffffffff85 :cc-equal jmp-cc-rel-imm8 @@ -139,9 +139,9 @@ eb e8 ~ 0xffffffffffffffe8 jmp-rel-imm8 ~ This is the routine named "exit". - 48 c7 c0 3c 00 00 00 ~ 0x0000003c :rax mov-reg64-imm32 + 48 c7 c0 3c 00 00 00 ~ 0x3c :rax mov-reg64-imm32 ~ syscall number for sys-exit - 48 c7 c7 00 00 00 00 ~ 0x00000000 :rdi mov-reg64-imm32 + 48 c7 c7 00 00 00 00 ~ 0x0 :rdi mov-reg64-imm32 ~ exit code 0f 05 ~ syscall @@ -154,7 +154,7 @@ 48 89 de ~ :rbx :rsi mov-reg64-reg64 ~ buffer pointer ~ We read one byte at a time, because it makes the loop structure simple. - 48 c7 c2 01 00 00 00 ~ 0x00000001 :rdx mov-reg64-imm32 + 48 c7 c2 01 00 00 00 ~ 0x1 :rdx mov-reg64-imm32 ~ buffer length 0f 05 ~ syscall c3 ~ ret @@ -163,41 +163,41 @@ 48 83 e8 30 ~ 0x30 :rax sub-reg64-imm8 ~ ASCII zero 7c 29 ~ 0x29 :cc-less jmp-cc-rel-imm8 - 48 83 f8 0a ~ 0x0a :rax cmp-reg64-imm8 + 48 83 f8 0a ~ 0xa :rax cmp-reg64-imm8 72 22 ~ 0x22 :cc-below jmp-cc-rel-imm8 48 83 e8 11 ~ 0x11 :rax sub-reg64-imm8 ~ ASCII capital A 7c 1d ~ 0x1d :cc-less jmp-cc-rel-imm8 - 48 83 c0 0a ~ 0x0a :rax add-reg64-imm8 + 48 83 c0 0a ~ 0xa :rax add-reg64-imm8 48 83 f8 10 ~ 0x10 :rax cmp-reg64-imm8 72 12 ~ 0x12 :cc-below jmp-cc-rel-imm8 48 83 e8 2a ~ 0x2a :rax sub-reg64-imm8 ~ ASCII lowercase a - 7c 0d ~ 0x0d :cc-less jmp-cc-rel-imm8 - 48 83 c0 0a ~ 0x0a :rax add-reg64-imm8 + 7c 0d ~ 0xd :cc-less jmp-cc-rel-imm8 + 48 83 c0 0a ~ 0xa :rax add-reg64-imm8 48 83 f8 10 ~ 0x10 :rax cmp-reg64-imm8 - 72 02 ~ 0x02 :cc-below jmp-cc-rel-imm8 - eb 01 ~ 0x01 jmp-rel-imm8 + 72 02 ~ 0x2 :cc-below jmp-cc-rel-imm8 + eb 01 ~ 0x1 jmp-rel-imm8 c3 ~ ret ~ These are the error handler routines. - 48 be ae 01 00 08 00 00 00 00 ~ 0x00000000080001ae :rsi mov-reg64-imm64 - 48 ba 0e 00 00 00 00 00 00 00 ~ 0x000000000000000e :rdx mov-reg64-imm64 + 48 be ae 01 00 08 00 00 00 00 ~ 0x80001ae :rsi mov-reg64-imm64 + 48 ba 0e 00 00 00 00 00 00 00 ~ 0xe :rdx mov-reg64-imm64 eb 2a ~ 0x2a jmp-rel-imm8 - 48 be c8 01 00 08 00 00 00 00 ~ 0x00000000080001c8 :rsi mov-reg64-imm64 - 48 ba 10 00 00 00 00 00 00 00 ~ 0x0000000000000010 :rdx mov-reg64-imm64 + 48 be c8 01 00 08 00 00 00 00 ~ 0x80001c8 :rsi mov-reg64-imm64 + 48 ba 10 00 00 00 00 00 00 00 ~ 0x10 :rdx mov-reg64-imm64 eb 14 ~ 0x14 jmp-rel-imm8 - 48 be bc 01 00 08 00 00 00 00 ~ 0x00000000080001bc :rsi mov-reg64-imm64 - 48 ba 0c 00 00 00 00 00 00 00 ~ 0x000000000000000c :rdx mov-reg64-imm64 - 48 c7 c0 01 00 00 00 ~ 0x00000001 :rax mov-reg64-imm32 + 48 be bc 01 00 08 00 00 00 00 ~ 0x80001bc :rsi mov-reg64-imm64 + 48 ba 0c 00 00 00 00 00 00 00 ~ 0xc :rdx mov-reg64-imm64 + 48 c7 c0 01 00 00 00 ~ 0x1 :rax mov-reg64-imm32 ~ syscall number for sys-write - 48 c7 c7 02 00 00 00 ~ 0x00000002 :rdi mov-reg64-imm32 + 48 c7 c7 02 00 00 00 ~ 0x2 :rdi mov-reg64-imm32 ~ file descriptor 2 is stderr 0f 05 ~ syscall - 48 c7 c0 3c 00 00 00 ~ 0x0000003c :rax mov-reg64-imm32 + 48 c7 c0 3c 00 00 00 ~ 0x3c :rax mov-reg64-imm32 ~ syscall number for sys-exit - 48 c7 c7 01 00 00 00 ~ 0x00000001 :rdi mov-reg64-imm32 + 48 c7 c7 01 00 00 00 ~ 0x1 :rdi mov-reg64-imm32 ~ exit code 0f 05 ~ syscall diff --git a/quine.asm b/quine.asm index 28f97d1..987c966 100644 --- a/quine.asm +++ b/quine.asm @@ -12034,6 +12034,8 @@ defword boot_source, 0x40 dq ": align-floor dup 3unroll /% swap drop * ; " + dq ": nexit 8 * control@ + r0 @ min control! ; " + ; Let's have strings now. dq ": s"" " dq " consume " diff --git a/transform.e b/transform.e index fc88992..167089b 100644 --- a/transform.e +++ b/transform.e @@ -1359,6 +1359,7 @@ allocate-transformation-state s" transformation-state" variable { ~ It exists, so we declare our use of it (that's also the only way to ~ get a value for it). + ~ : provide-string-copy swap-transform-variables intern-label use-label swap-transform-variables @@ -1374,6 +1375,7 @@ allocate-transformation-state s" transformation-state" variable ~ ~ Fortunately we don't have to look at it, just append it to the log ~ and clean up. + ~ : 8 # (codeword pointer) offset-to-target-address-space , drop dropstring 0 exit } if |