From e72d38a04c6bdac29c362a67f665fac953bff484 Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Mon, 11 Jan 2021 01:23:31 +0900 Subject: [PATCH] Significantly rewirte handwrite version --- planck.xxd | 274 +++++++++++++++++++++++++++++------------------------ 1 file changed, 148 insertions(+), 126 deletions(-) diff --git a/planck.xxd b/planck.xxd index 963ab4c..e7b85e9 100644 --- a/planck.xxd +++ b/planck.xxd @@ -6,171 +6,193 @@ 00000028: 3400 2000 0100 0000 e_ehsize,e_phentsize,e_phnum,e_shentsize 00000030: 0000 0000 0100 0000 e_shnum,e_shstrndx,p_type=PT_LOAD 00000038: 0000 0000 0080 0408 p_offset,p_vaddr=0x08048000 -00000040: 0000 0000 f003 0000 p_paddr,p_filesz +00000040: 0000 0000 0004 0000 p_paddr,p_filesz 00000048: 0000 2000 0700 0000 p_memsz(128KB),p_flags=PF_X|PF_W|PF_R -00000050: 0010 0000 f083 0408 p_align, -00000058: c483 0408 0000 0000 , -00000060: e480 0408 5c81 0408 key, find -00000068: 8881 0408 3081 0408 execute, jump +00000050: 0010 0000 0084 0408 p_align, +00000058: 3882 0408 0000 0000 , +00000060: c080 0408 f080 0408 key, find +00000068: fc80 0408 d880 0408 execute, jump 00000070: f0ff ffff be60 8004 -16, movl $interpreter, %esi 00000078: 08bd 0080 0608 8925 movl $0x08068000,%ebp; movl %esp,sp0; 00000080: 5c80 0408 adff 2000 next; 00000088: 0000 0000 0151 0000 Q: quit -00000090: 9480 0408 31db b801 xorl %ebx,%ebx; mov $SYS_EXIT,%eax; -00000098: 0000 00cd 8000 0000 int $0x80; +00000090: 4482 0408 0000 0000 +00000094: 8880 0408 0143 0000 C: cell +0000009c: 4d82 0408 0000 0000 +000000a0: 9480 0408 0168 0000 h: &here +000000a8: 5282 0408 0000 0000 +000000ac: a080 0408 016c 0000 l: &latest +000000b4: 5a82 0408 0000 0000 +000000b8: ac80 0408 016b 0000 k: key +000000c0: 6282 0408 0000 0000 +000000c4: b880 0408 0174 0000 t: type +000000cc: 7c82 0408 0000 0000 +000000d0: c480 0408 016a 0000 j: branch +000000d8: 9282 0408 0000 0000 +000000dc: d080 0408 014a 0000 J: 0branch +000000e4: 9782 0408 0000 0000 +000000e8: dc80 0408 0166 0000 f: find +000000f0: a082 0408 0000 0000 +000000f4: e880 0408 0178 0000 x: execute +000000fc: c082 0408 0000 0000 +00000100: f480 0408 0140 0000 @: fetch +00000108: c382 0408 0000 0000 +0000010c: 0081 0408 0121 0000 !: store +00000114: ca82 0408 0000 0000 +00000118: 0c81 0408 013f 0000 ?: cfetch +00000120: d182 0408 0000 0000 +00000124: 1881 0408 0124 0000 $: cstore +0000012c: d982 0408 0000 0000 +00000130: 2481 0408 0164 0000 d: dfetch +00000138: e082 0408 0000 0000 +0000013c: 3081 0408 0144 0000 D: dstore +00000144: e482 0408 0000 0000 +00000148: 3c81 0408 0172 0000 r: rfetch +00000150: e882 0408 0000 0000 +00000154: 4881 0408 0152 0000 R: rstore +0000015c: ec82 0408 0000 0000 +00000160: 5481 0408 0169 0000 i: docol +00000168: fe82 0408 0000 0000 +0000016c: 6081 0408 0165 0000 e: exit +00000174: 0683 0408 0000 0000 +00000178: 6c81 0408 014c 0000 L: lit +00000180: 0f83 0408 0000 0000 +00000184: 7881 0408 0153 0000 S: litstring +0000018c: 1483 0408 0000 0000 +00000190: 8481 0408 012b 0000 +: add +00000198: 1d83 0408 0000 0000 +0000019c: 9081 0408 012d 0000 -: sub +000001a4: 2483 0408 0000 0000 +000001a8: 9c81 0408 012a 0000 *: mul +000001b0: 2b83 0408 0000 0000 +000001b4: a881 0408 012f 0000 /: divmod +000001bc: 3483 0408 0000 0000 +000001c0: b481 0408 0126 0000 &: and +000001c8: 3f83 0408 0000 0000 +000001cc: c081 0408 017c 0000 |: or +000001d4: 4683 0408 0000 0000 +000001d8: cc81 0408 015e 0000 ^: xor +000001e0: 4d83 0408 0000 0000 +000001e4: d881 0408 013c 0000 <: less +000001ec: 5483 0408 0000 0000 +000001f0: e481 0408 0175 0000 u: uless (unsigned less) +000001f8: 6283 0408 0000 0000 +000001fc: f081 0408 013d 0000 =: equal +00000204: 7083 0408 0000 0000 +00000208: fc81 0408 017b 0000 {: shl +00000210: 7e83 0408 0000 0000 +00000214: 0882 0408 017d 0000 }: shr +0000021c: 8683 0408 0000 0000 +00000220: 1482 0408 0129 0000 ): sar +00000228: 8e83 0408 0000 0000 +0000022c: 2082 0408 0176 0000 v: argv +00000234: 9683 0408 0000 0000 +00000238: 2c82 0408 0156 0000 V: version +00000240: a583 0408 0000 0000 -000000a0: 8880 0408 0143 0000 C: cellsize -000000a8: ac80 0408 6a04 adff pushl $4; -000000b0: 2000 0000 0000 0000 next; +00000244: 31db b801 0000 00cd (quit) xorl %ebx,%ebx; mov $SYS_EXIT,%eax; +0000024c: 8000 0000 0000 0000 int $0x80; -000000b4: a080 0408 0168 0000 h: here -000000bc: c080 0408 6854 8004 pushl $here; -000000c4: 08ad ff20 0000 0000 next; +0000024d: 6a04 adff 2000 0000 (cell) pushl $4; next; -000000c8: b480 0408 016c 0000 l: latest -000000d0: d480 0408 6858 8004 pushl $latest; -000000d8: 08ad ff20 0000 0000 next; +00000252: 6854 8004 08ad ff20 (&here) pushl $here; next; -000000dc: c880 0408 016b 0000 k: key -000000e4: e880 0408 31c0 50ba xorl %eax,%eax; pushl %eax; movl $1,%edx; -000000ec: 0100 0000 89e1 31db movl %esp,%ecx; xorl %ebx,%ebx (STDIN); -000000f4: b803 0000 00cd 8085 movl $SYS_READ,%eax; int $0x80; test %eax,%eax; -000000fc: c076 95ad ff20 0000 jbe 0x08048094(-107); +0000025a: 6858 8004 08ad ff20 (&latest) pushl $latest; next; -00000104: dc80 0408 0174 0000 t: type -0000010c: 1081 0408 ba01 0000 movl $1,%edx; -00000114: 0089 e189 d3b8 0400 movl %esp,%ecx; movl $1,%ebx (STDOUT); -0000011c: 0000 cd80 83c4 04ad movl $SYS_WRITE,%eax; int $0x80; -00000124: ff20 0000 0000 0000 addl $4,%esp; next; +00000262: 31c0 50ba 0100 0000 (key) xorl %eax,%eax; pushl %eax; movl $1,%edx; +0000026a: 89e1 31db b803 0000 movl %esp,%ecx; xorl %ebx,%ebx (STDIN=0); +00000272: 00cd 8085 c076 cbad movl $SYS_READ,%eax; int $0x80; test %eax,%eax; +0000027a: ff20 0000 0000 0000 jbe 0x08048244(-53); next; -00000128: 0481 0408 016a 0000 j: jump -00000130: 3481 0408 0336 adff addl (%esi),%esi; next; -00000138: 2000 0000 0000 0000 +0000027c: ba01 0000 0089 e189 (type) movl $1,%edx; movl %esp,%ecx; +00000284: d3b8 0400 0000 cd80 movl $1,%ebx (STDOUT=1);movl $SYS_WRITE,%eax; +0000028c: 83c4 04ad ff20 0000 int $0x80; addl $4,%esp; next; -0000013c: 2881 0408 014a 0000 J: jump if zero -00000144: 4881 0408 5885 c074 popl %eax; test %eax,%eax;je 0x08048134(-25) -0000014c: e7ad adff 2000 0000 lodsl; next; +00000292: 0336 adff 2000 0000 (branch) addl (%esi),%esi; next; -00000154: 3c81 0408 0166 0000 f: find -0000015c: 6081 0408 8a24 24b0 movb (%esp),%ah;movb $1,%al; -00000164: 018b 0d58 8004 088b movl latest,%ecx;<1>movl 4(%ecx),%ebx; -0000016c: 5904 6639 c374 048b cmpw %ax,%bx;je 2f;movl (%ecx),%ecx -00000174: 09eb f483 c108 890c jmp 1b(-12);<2>addl $8,%ecx;movl %ecx,(%esp) -0000017c: 24ad ff20 0000 0000 next; +00000297: 5885 c074 f6ad adff (0branch) popl %eax; test %eax,%eax; +0000029f: 2000 0000 0000 0000 je 0x08048292(-10); lodsl; next; -00000180: 5481 0408 0178 0000 x: execute -00000188: 8c81 0408 58ff 2000 popl %eax; jmp *(%eax) +000002a0: 8a24 24b0 018b 0d58 (find) movb (%esp),%ah;movb $1,%al; +000002a8: 8004 088b 5904 6639 movl latest,%ecx;<1>movl 4(%ecx),%ebx; +000002b0: c374 048b 09eb f483 cmpw %ax,%bx;je 2f;movl (%ecx),%ecx +000002b8: c108 890c 24ad ff20 jmp 1b(-12);<2>addl $8,%ecx;movl %ecx,(%esp); next; -00000190: 8081 0408 0140 0000 @: fetch -00000198: 9c81 0408 588b 0050 popl %eax; movl (%eax),%eax;push %eax; -000001a0: adff 2000 0000 0000 next; +000002c0: 58ff 2000 0000 0000 (execute) popl %eax; jmp *(%eax) -000001a4: 9081 0408 0121 0000 !: store -000001ac: b081 0408 585b 8918 popl %eax; popl %ebx; movl %ebx,(%eax) -000001b4: adff 2000 0000 0000 next; +000002c3: 588b 0050 adff 2000 (fetch) popl %eax; movl (%eax),%eax;push %eax; next; -000001b8: a481 0408 013f 0000 ?: cfetch -000001c0: c481 0408 580f be00 popl %eax; movsbl (%eax),%eax; -000001c8: 50ad ff20 0000 0000 pushl %eax; next; +000002ca: 585b 8918 adff 2000 (store) popl %eax; popl %ebx; movl %ebx,(%eax); next -000001cc: b881 0408 0124 0000 $: cstore -000001d4: d881 0408 585b 8818 popl %eax; popl %ebx; movb %bl,(%eax) -000001dc: adff 2000 0000 0000 next; +000002d1: 580f be00 50ad ff20 (cfetch) popl %eax; movsbl (%eax),%eax; next; -000001e0: cc81 0408 0164 0000 d: dfetch -000001e8: ec81 0408 54ad ff20 movl %esp,%eax; pushl %eax; next; +000002d9: 585b 8818 adff 2000 (cstore) popl %eax; popl %ebx; movb %bl,(%eax); next; -000001f0: e081 0408 0144 0000 D: dstore -000001f8: fc81 0408 5cad ff20 popl %eax; movl %eax,%esp; next; +000002e0: 54ad ff20 0000 0000 (dfetch) movl %esp,%eax; pushl %eax; next; -00000200: f081 0408 0172 0000 r: rfetch -00000208: 0c82 0408 55ad ff20 pushl %ebp; next; +000002e4: 5cad ff20 0000 0000 (dstore) popl %eax; movl %eax,%esp; next; -00000210: 0082 0408 0152 0000 R: rstore -00000218: 1c82 0408 5dad ff20 popl %ebp; next; +000002e8: 55ad ff20 0000 0000 (rfetch) pushl %ebp; next; -00000220: 1082 0408 0169 0000 i: docol -00000228: 2c82 0408 6834 8204 pushl $docol; -00000230: 08ad ff20 0000 0000 next; -00000234: 8d6d fc89 7500 83c0 rpush %esi; addl $4,%eax -0000023c: 0489 c6ad ff20 0000 movl %eax,%esi; next; +000002ec: 5dad ff20 0000 0000 (rstore) popl %ebp; next; -00000244: 2082 0408 0165 0000 e: exit -0000024c: 5082 0408 8b75 008d rpop %esi -00000254: 6d04 adff 2000 0000 next +000002f0: 8d6d fc89 7500 83c0 rpush %esi; addl $4,%eax +000002f8: 0489 c6ad ff20 0000 movl %eax,%esi; next; -0000025c: 4482 0408 014c 0000 L: lit -00000264: 6882 0408 ad50 adff lodsl; pushl %eax; next; -0000026c: 2000 0000 0000 0000 +000002fe: 68f0 8204 08ad ff20 (docol) pushl $docol; next; -00000270: 5c82 0408 0153 0000 S: litstring -00000278: 7c82 0408 ad56 01c6 lodsl; pushl %esi; addl %eax,%esi; -00000280: adff 2000 0000 0000 next; +00000306: 8b75 008d 6d04 adff (exit) rpop %esi next; +0000030e: 2000 0000 0000 0000 -00000284: 7082 0408 012b 0000 +: add -0000028c: 9082 0408 5801 0424 popl %eax; addl %eax,(%esp) -00000294: adff 2000 0000 0000 next; +0000030f: ad50 adff 2000 0000 (lit) lodsl; pushl %eax; next; -00000298: 8482 0408 012d 0000 -: sub -000002a0: a482 0408 5829 0424 popl %eax; subl %eax,(%esp) -000002a8: adff 2000 0000 0000 next; +00000314: ad56 01c6 adff 2000 (litstring)lodsl; pushl %esi; addl %eax,%esi; next; -000002ac: 9882 0408 012a 0000 *: mul -000002b4: b882 0408 585b 0faf popl %eax; popl %ebx; imul %ebx,%eax -000002bc: c350 adff 2000 0000 pushl %eax; next; +0000031d: 5801 0424 adff 2000 (add) popl %eax; addl %eax,(%esp); next; -000002c4: ac82 0408 012f 0000 /: divmod -000002cc: d082 0408 31d2 5b58 xorl %edx,%edx; popl %ebx; popl %eax -000002d4: f7fb 5250 adff 2000 idiv %ebx; pushl %edx; pushl %eax; next; +00000324: 5829 0424 adff 2000 (sub) popl %eax; subl %eax,(%esp); next; -000002dc: c482 0408 0126 0000 &: and -000002e4: e882 0408 5821 0424 popl %eax; andl %eax,(%esp) -000002ec: adff 2000 0000 0000 next; next; +0000032b: 585b 0faf c350 adff (mul) popl %eax; popl %ebx; imul %ebx,%eax +00000333: 2000 0000 0000 0000 pushl %eax; next; -000002f0: dc82 0408 017c 0000 |: or -000002f8: fc82 0408 5809 0424 popl %eax; orl %eax,(%esp) -00000300: adff 2000 0000 0000 next; +00000334: 31d2 5b58 f7fb 5250 (divmod) xorl %edx,%edx; popl %ebx; popl %eax +0000033c: adff 2000 0000 0000 idiv %ebx; pushl %edx; pushl %eax; next; -00000304: f082 0408 015e 0000 ^: xor -0000030c: 1083 0408 5831 0424 popl %eax; andl %eax,(%esp) -00000314: adff 2000 0000 0000 next; +0000033f: 5821 0424 adff 2000 (and) popl %eax; andl %eax,(%esp); next; -00000318: 0483 0408 013c 0000 <: less -00000320: 2483 0408 585b 39c3 popl %eax; popl %ebx; cmpl %eax,%ebx -00000328: 0f9c c00f b6c0 50ad setl %al; movzbl %al, %eax; pushl %eax; next; -00000330: ff20 0000 0000 0000 +00000346: 5809 0424 adff 2000 (or) popl %eax; orl %eax,(%esp); next; -00000334: 1883 0408 0175 0000 u: less (unsigned) -0000033c: 4083 0408 585b 39c3 popl %eax; popl %ebx; cmpl %eax,%ebx -00000344: 0f92 c00f b6c0 50ad setb %al; movzbl %al, %eax; pushl %eax; next; -0000034c: ff20 0000 0000 0000 +0000034d: 5831 0424 adff 2000 (xor) popl %eax; andl %eax,(%esp); next; -00000350: 3483 0408 013d 0000 =: equal -00000358: 5c83 0408 585b 39c3 popl %eax; popl %ebx; cmpl %eax,%ebx -00000360: 0f94 c00f b6c0 50ad setl %al; movzbl %al, %eax; pushl %eax; next; -00000368: ff20 0000 0000 0000 +00000354: 585b 39c3 0f9c c00f (less) popl %eax; popl %ebx; cmpl %eax,%ebx +0000035c: b6c0 50ad ff20 0000 setl %al; movzbl %al, %eax; pushl %eax; next; -0000036c: 5083 0408 017b 0000 {: shl -00000374: 7883 0408 5958 d3e0 popl %ecx; popl %eax; shll %cl,%eax -0000037c: 50ad ff20 0000 0000 pushl %eax; next; +00000362: 585b 39c3 0f92 c00f (uless) popl %eax; popl %ebx; cmpl %eax,%ebx +0000036a: b6c0 50ad ff20 0000 setb %al; movzbl %al, %eax; pushl %eax; next; -00000380: 6c83 0408 017d 0000 }: shr -00000388: 8c83 0408 5958 d3e8 popl %ecx; popl %eax; shrl %cl,%eax -00000390: 50ad ff20 0000 0000 pushl %eax; next; +00000370: 585b 39c3 0f94 c00f (equal) popl %eax; popl %ebx; cmpl %eax,%ebx +00000378: b6c0 50ad ff20 0000 setl %al; movzbl %al, %eax; pushl %eax; next; -00000394: 8083 0408 0129 0000 ): sar -0000039c: a083 0408 5958 d3f8 popl %ecx; popl %eax; sarl %cl,%eax -000003a4: 50ad ff20 0000 0000 pushl %eax; next; +0000037e: 5958 d3e0 50ad ff20 (shl) popl %ecx; popl %eax; shll %cl,%eax next; -000003a8: 9483 0408 0176 0000 v: argv -000003b0: b483 0408 8b05 5c80 movl sp0,%eax; -000003b8: 0408 8d58 0453 ff30 leal 4(%eax),%ebx; pushl %ebx; pushl (%eax); -000003c0: adff 2000 0000 0000 next; +00000386: 5958 d3e8 50ad ff20 (shr) popl %ecx; popl %eax; shrl %cl,%eax next; -000003c4: a883 0408 0156 0000 V: version -000003cc: d083 0408 68d8 8304 pushl $version -000003d4: 08ad ff20 6861 6e64 next; hand -000003dc: 2d77 7269 7474 656e -written -000003e4: 2069 3338 362d 6c69 i386-li -000003ec: 6e75 7800 +0000038e: 5958 d3f8 50ad ff20 (sar) popl %ecx; popl %eax; sarl %cl,%eax; next; + +00000396: 8b05 5c80 0408 8d58 (argv) movl sp0,%eax; leal 4(%eax),%ebx +0000039e: 0453 ff30 adff 2000 pushl %ebx; pushl (%eax); next; + +000003a5: 68b0 8304 08ad ff20 (version) pushl $version; next +000003ad: 0000 0000 0000 0000 padding + +000003b0: 6933 3836 2d6c 696e i386-lin +000003b8: 7578 2068 616e 6477 ux handw +000003c0: 7269 7465 3a43 6f70 rite:Cop +000003c8: 7972 6967 6874 2028 yright ( +000003d0: 6329 2032 3032 3120 c) 2021 +000003d8: 4b6f 6963 6869 204e Koichi N +000003e0: 616b 616d 7572 6120 akamura +000003e8: 3c6b 6f69 6368 6940