From e889b122cee2eb60cd1577c22560c8918b30d749 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Mon, 5 Oct 2026 01:58:58 -0700 Subject: move around a bunch of the files that aren't actually in use to better describe their status Force-Push: yes Change-Id: If5ef70b7872700ff36ef07f20aac1f3b991dff45 --- describe-data.sed | 49 --------------------- describe-heap.sed | 11 ----- describe-redact.sed | 5 --- exit-code.asm | 99 ------------------------------------------ exit-code.gnu.asm | 29 ------------- experiments/mutable-modules.e | 74 +++++++++++++++++++++++++++++++ experiments/recompile.e | 12 +++++ historical/describe-data.sed | 49 +++++++++++++++++++++ historical/describe-heap.sed | 11 +++++ historical/describe-redact.sed | 5 +++ historical/exit-code.asm | 99 ++++++++++++++++++++++++++++++++++++++++++ historical/exit-code.gnu.asm | 29 +++++++++++++ recompile.e | 12 ----- 13 files changed, 279 insertions(+), 205 deletions(-) delete mode 100644 describe-data.sed delete mode 100644 describe-heap.sed delete mode 100644 describe-redact.sed delete mode 100644 exit-code.asm delete mode 100644 exit-code.gnu.asm create mode 100644 experiments/mutable-modules.e create mode 100644 experiments/recompile.e create mode 100644 historical/describe-data.sed create mode 100644 historical/describe-heap.sed create mode 100644 historical/describe-redact.sed create mode 100644 historical/exit-code.asm create mode 100644 historical/exit-code.gnu.asm delete mode 100644 recompile.e diff --git a/describe-data.sed b/describe-data.sed deleted file mode 100644 index 77f3d8e..0000000 --- a/describe-data.sed +++ /dev/null @@ -1,49 +0,0 @@ -# ./quine | sed -f describe-data.sed > data.txt - -:start -/0000000008/!d -/^0000000008/bmain -bstart - -:main -n - -s/_/-/g -s/\/3roll/g -s/\/3unroll/g -s/\/2dup/g -s/\/2drop/g -s/^zbranch\>/0branch/g -s/\([^"]\)\/\10branch/g -s/\/=/g -s/\/!=/g -s/\/>/g -s/\//>=/g -s/\/<=/g -s/\([^a-z]\)-unsigned\>/\1unsigned/g -s/\\([^-]\)/\/%\1/g -s/\\([^-]\)/*\1/g -s/\\([^-]\)/-\1/g -s/\\([^-]\)/+\1/g -s/\<\([er][acdb]x\)\>/:\1/g -s/\<\([er]\?\([sb]p\|[sd]i\)\)\>/:\1/g -s/\<\([acdb][lhx]\)\>/:\1/g -s/\<\(r[89]\|r1[0-5]\)\>/:\1/g -s/\([^-]\)\/\1@/g -s/\/\1!/g -s/\/+!/g -s/\/-!/g -s/\/value@/g -s/\/value!/g -s/\/control@/g -s/\/control!/g -s/\/entry-flags@/g -s/\/entry-flags!/g -s/\/@/g -s/\/!/g - -bmain - diff --git a/describe-heap.sed b/describe-heap.sed deleted file mode 100644 index f21781b..0000000 --- a/describe-heap.sed +++ /dev/null @@ -1,11 +0,0 @@ -# ./quine | sed -f describe-heap.sed > heap.txt - -:main -/^0000000008/bdrop -n -bmain - -:drop -s/.*// -N -bdrop diff --git a/describe-redact.sed b/describe-redact.sed deleted file mode 100644 index 1303058..0000000 --- a/describe-redact.sed +++ /dev/null @@ -1,5 +0,0 @@ -# Pipe either memory segment's output through this after the other script, -# to remove things that depend on exact addresses. - -/^[0-9a-f]\{16\}/d -s/^ lit [0-9]\+ exit$/ lit REDACTED exit/ diff --git a/exit-code.asm b/exit-code.asm deleted file mode 100644 index 498bfc4..0000000 --- a/exit-code.asm +++ /dev/null @@ -1,99 +0,0 @@ -; fasmg exit-code.asm exit-code - -macro mov.d target, source - match =rax?, target - db 0x48, 0xC7, 0xC0 -; 48 eAX REX.W prefix -; (DEC is the 32-bit meaning, ignore it) -; eAX -> register identifier, -; width depends on operand -; REX.W -> set 64-bit operand mode -; c7 Grp 11^1A - MOV Ev, Iz -; immediate to register -; 1A -> bits 5,4,3 of ModR/M are opcode -; extension -; E -> modR/M byte to follow for operand -; v -> word of appropriate size -; I -> immediate data -; z -> 32-bit operand -; c0 ModR/M byte -; 0b11000000 -; 11 mod: always 11 -; 000 op/reg: Mov Ev, Iz -; 00x w absent -; 0 w (ignored) - dd source - else match =rdi, target - db 0x48, 0xC7, 0xC7 -; 7: 48 c7 c7 2a 00 00 00 mov $0x2a,%rdi -; 48 eAX REX.W prefix -; (DEC is the 32-bit meaning, ignore it) -; c7 Grp 11^1A - MOV Ev, Iz -; immediate to register -; 1A -> bits 5,4,3 of ModR/M are opcode -; extension -; Ev -> ModR/M to follow for 32-bit operand -; Iz -> Immediate data, 32-bits -; c7 ModR/M byte -; 0b11000111 -; 11 mod: always 11 -; 000 op/reg: Mov Ev, Iz -; 11x w present -; 1 w true; use EDI - dd source - end match -end macro - -macro syscall - db 0x0F, 0x05 -; 0f two-byte escape -; 05 syscall ^ o64 -end macro - - - - -org 0x08048000 - -elf_header: - db 0x7F, "ELF" - db 2 ; 64-bit - db 1 ; little-endian - db 1 ; ELF header format version 1 - db 0 ; System-V ABI - db 8 dup 0 ; (padding) - - dw 2 ; executable - dw 0x3E ; Intel x86-64 - dd 1 ; ELF format version - - dq _start ; entry point - dq program_header - $$ ; program header offset - dq 0 ; section header offset - dd 0 ; processor flags - dw elf_header_size - dw program_header_entry_size - dw 1 ; number of program header entries - dw 0 ; section header entry size - dw 0 ; number of section header entries - dw 0 ; section name string table index -elf_header_size = $ - elf_header - -program_header: - dd 1 ; "loadable" segment type - dd 0x05 ; read+execute permission - dq 0 ; offset in file - dq $$ ; virtual address - dq 0 ; (padding) - dq file_size ; size in file - dq file_size ; size in memory - dq 0 ; segment alignment -program_header_entry_size = $ - program_header - -_start: - mov.d rax, 60 - mov.d rdi, 42 - syscall - -file_size = $ - $$ - diff --git a/exit-code.gnu.asm b/exit-code.gnu.asm deleted file mode 100644 index 48b7e62..0000000 --- a/exit-code.gnu.asm +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file was a very early example, written by consulting [1]. It was - * useful primarily to see how the GNU assembler handles these opcodes, to - * better understand the encoding. - * - * [1] https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html - * - * - * gcc -o exit-code -nostartfiles -nostdlib exit-code.gnu.asm && ./exit-code ; echo $? - * - * or - * - * as -o exit-code.o exit-code.gnu.asm && ld -s -o exit-code exit-code.o && ./exit-code; echo $? - * - * Can't use nasm, nasm is 32-bit only. - * - * Since you get a nice clean file, you can then do: - * - * objdump --disassemble exit-code - */ -.text - -.global _start - -_start: - mov $60, %eax - mov $42, %edi - syscall - diff --git a/experiments/mutable-modules.e b/experiments/mutable-modules.e new file mode 100644 index 0000000..5180e4d --- /dev/null +++ b/experiments/mutable-modules.e @@ -0,0 +1,74 @@ +~ STATUS OF THIS FILE +~ this is scrap being collected in one place, in case it ever becomes relevant +~ again. it likely won't. at one time, the thinking was that the +~ transformation system might be easier to develop with this module facility, +~ but that turned out not to be the case. + + +~ Modules and module contexts +~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~ +~ A module is a set of related words which are, normally, only visible to +~ each other. All the words defined as part of a module must be defined +~ together; you begin defining a module by invoking the word "module:" +~ followed by the module's name, and end by invoking "end-module". Words +~ created while defining a module are flagged as visible until "end-module" is +~ called, at which point their entries are edited in place to be marked as +~ hidden, which will prevent accidental references to them from outside the. +~ module. +~ +~ Additionally, the module's name becomes a word which becomes visible +~ after end-module runs, and provides a way to call the otherwise-hidden words +~ within the module. When written as a word, the module's name is followed by +~ the name of a word to call, which it reads and looks up within the module. +~ The module-name word then either compiles or executes a call to the word +~ that's found, depending on the mode the interpreter is in. +~ +~ Within a module, it is permissible to define "contextual" words. Whereas +~ any normal word in Evocation has a single interface, some specific +~ expectations for how the value stack looks when it's called and how that's +~ different after it returns, contextual words have one interface that applies +~ to calls from outside the module or from non-contextual words within the +~ module, and another interface that applies when they call each other within +~ the same module. +~ +~ TODO and what are those interfaces? +~ WHAT ARE THOSE INTERFACES, Irenes? + +here @ 0 , s" context-stack" variable + +: module: + word value@ create dropstring docol , make-module-header + [ dup entry-to-execution-token , ] ; + + + + +module: amazing-transformation 8 2 * allocate ; + +~ ( -- transformee pointer) +: transformee amazing-transformation @ ; +: transformation-mode amazing-transformation @ 8 + ; + +: frob-transformee + transformee @ + ~ ... + transformee ! ; + +~ no parameters +: transform-one + ~ ... complex stuff here ... + ; + +~ (transformee -- transformee) +: transform + 8 2 * allocate amazing-transformation ! + transformee ! + { transform-one + { transformee @ exit } if + } forever ; + +end-module + +amazing-transformation transform + diff --git a/experiments/recompile.e b/experiments/recompile.e new file mode 100644 index 0000000..c6a6f7a --- /dev/null +++ b/experiments/recompile.e @@ -0,0 +1,12 @@ +~ (entry pointer --) +: recompile + dup word-heading + dup guess-entry-end swap entry-to-execution-token 8 + + { 2dup < } + { space dup @ dup is-codeword + { execution-token-to-entry entry-to-name emitstring } + { . } if-else + 8 + } while newline ; + +' , recompile +bye diff --git a/historical/describe-data.sed b/historical/describe-data.sed new file mode 100644 index 0000000..77f3d8e --- /dev/null +++ b/historical/describe-data.sed @@ -0,0 +1,49 @@ +# ./quine | sed -f describe-data.sed > data.txt + +:start +/0000000008/!d +/^0000000008/bmain +bstart + +:main +n + +s/_/-/g +s/\/3roll/g +s/\/3unroll/g +s/\/2dup/g +s/\/2drop/g +s/^zbranch\>/0branch/g +s/\([^"]\)\/\10branch/g +s/\/=/g +s/\/!=/g +s/\/>/g +s/\//>=/g +s/\/<=/g +s/\([^a-z]\)-unsigned\>/\1unsigned/g +s/\\([^-]\)/\/%\1/g +s/\\([^-]\)/*\1/g +s/\\([^-]\)/-\1/g +s/\\([^-]\)/+\1/g +s/\<\([er][acdb]x\)\>/:\1/g +s/\<\([er]\?\([sb]p\|[sd]i\)\)\>/:\1/g +s/\<\([acdb][lhx]\)\>/:\1/g +s/\<\(r[89]\|r1[0-5]\)\>/:\1/g +s/\([^-]\)\/\1@/g +s/\/\1!/g +s/\/+!/g +s/\/-!/g +s/\/value@/g +s/\/value!/g +s/\/control@/g +s/\/control!/g +s/\/entry-flags@/g +s/\/entry-flags!/g +s/\/@/g +s/\/!/g + +bmain + diff --git a/historical/describe-heap.sed b/historical/describe-heap.sed new file mode 100644 index 0000000..f21781b --- /dev/null +++ b/historical/describe-heap.sed @@ -0,0 +1,11 @@ +# ./quine | sed -f describe-heap.sed > heap.txt + +:main +/^0000000008/bdrop +n +bmain + +:drop +s/.*// +N +bdrop diff --git a/historical/describe-redact.sed b/historical/describe-redact.sed new file mode 100644 index 0000000..1303058 --- /dev/null +++ b/historical/describe-redact.sed @@ -0,0 +1,5 @@ +# Pipe either memory segment's output through this after the other script, +# to remove things that depend on exact addresses. + +/^[0-9a-f]\{16\}/d +s/^ lit [0-9]\+ exit$/ lit REDACTED exit/ diff --git a/historical/exit-code.asm b/historical/exit-code.asm new file mode 100644 index 0000000..498bfc4 --- /dev/null +++ b/historical/exit-code.asm @@ -0,0 +1,99 @@ +; fasmg exit-code.asm exit-code + +macro mov.d target, source + match =rax?, target + db 0x48, 0xC7, 0xC0 +; 48 eAX REX.W prefix +; (DEC is the 32-bit meaning, ignore it) +; eAX -> register identifier, +; width depends on operand +; REX.W -> set 64-bit operand mode +; c7 Grp 11^1A - MOV Ev, Iz +; immediate to register +; 1A -> bits 5,4,3 of ModR/M are opcode +; extension +; E -> modR/M byte to follow for operand +; v -> word of appropriate size +; I -> immediate data +; z -> 32-bit operand +; c0 ModR/M byte +; 0b11000000 +; 11 mod: always 11 +; 000 op/reg: Mov Ev, Iz +; 00x w absent +; 0 w (ignored) + dd source + else match =rdi, target + db 0x48, 0xC7, 0xC7 +; 7: 48 c7 c7 2a 00 00 00 mov $0x2a,%rdi +; 48 eAX REX.W prefix +; (DEC is the 32-bit meaning, ignore it) +; c7 Grp 11^1A - MOV Ev, Iz +; immediate to register +; 1A -> bits 5,4,3 of ModR/M are opcode +; extension +; Ev -> ModR/M to follow for 32-bit operand +; Iz -> Immediate data, 32-bits +; c7 ModR/M byte +; 0b11000111 +; 11 mod: always 11 +; 000 op/reg: Mov Ev, Iz +; 11x w present +; 1 w true; use EDI + dd source + end match +end macro + +macro syscall + db 0x0F, 0x05 +; 0f two-byte escape +; 05 syscall ^ o64 +end macro + + + + +org 0x08048000 + +elf_header: + db 0x7F, "ELF" + db 2 ; 64-bit + db 1 ; little-endian + db 1 ; ELF header format version 1 + db 0 ; System-V ABI + db 8 dup 0 ; (padding) + + dw 2 ; executable + dw 0x3E ; Intel x86-64 + dd 1 ; ELF format version + + dq _start ; entry point + dq program_header - $$ ; program header offset + dq 0 ; section header offset + dd 0 ; processor flags + dw elf_header_size + dw program_header_entry_size + dw 1 ; number of program header entries + dw 0 ; section header entry size + dw 0 ; number of section header entries + dw 0 ; section name string table index +elf_header_size = $ - elf_header + +program_header: + dd 1 ; "loadable" segment type + dd 0x05 ; read+execute permission + dq 0 ; offset in file + dq $$ ; virtual address + dq 0 ; (padding) + dq file_size ; size in file + dq file_size ; size in memory + dq 0 ; segment alignment +program_header_entry_size = $ - program_header + +_start: + mov.d rax, 60 + mov.d rdi, 42 + syscall + +file_size = $ - $$ + diff --git a/historical/exit-code.gnu.asm b/historical/exit-code.gnu.asm new file mode 100644 index 0000000..48b7e62 --- /dev/null +++ b/historical/exit-code.gnu.asm @@ -0,0 +1,29 @@ +/* + * This file was a very early example, written by consulting [1]. It was + * useful primarily to see how the GNU assembler handles these opcodes, to + * better understand the encoding. + * + * [1] https://www.muppetlabs.com/~breadbox/software/tiny/teensy.html + * + * + * gcc -o exit-code -nostartfiles -nostdlib exit-code.gnu.asm && ./exit-code ; echo $? + * + * or + * + * as -o exit-code.o exit-code.gnu.asm && ld -s -o exit-code exit-code.o && ./exit-code; echo $? + * + * Can't use nasm, nasm is 32-bit only. + * + * Since you get a nice clean file, you can then do: + * + * objdump --disassemble exit-code + */ +.text + +.global _start + +_start: + mov $60, %eax + mov $42, %edi + syscall + diff --git a/recompile.e b/recompile.e deleted file mode 100644 index c6a6f7a..0000000 --- a/recompile.e +++ /dev/null @@ -1,12 +0,0 @@ -~ (entry pointer --) -: recompile - dup word-heading - dup guess-entry-end swap entry-to-execution-token 8 + - { 2dup < } - { space dup @ dup is-codeword - { execution-token-to-entry entry-to-name emitstring } - { . } if-else - 8 + } while newline ; - -' , recompile -bye -- cgit 1.4.1