From 7674970c2d8a6fe12979c1bdc672ad17b9aab5fe Mon Sep 17 00:00:00 2001 From: Koichi Nakamura Date: Tue, 29 Dec 2020 14:41:03 +0900 Subject: [PATCH] Add "f" --- README.md | 21 +++++++++++---------- planck.xxd | 14 ++++++++++---- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 14079c4..248a560 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,14 @@ $ make # Builtin Words -| char | semantics | -|:----:|:-----------------------------------------:| -| Q | ( -- ) Exit the process | -| C | ( -- n ) The size of Cells | -| h | ( -- addr ) The address of 'here' cell | -| l | ( -- addr ) The address of 'latest' cell | -| k | ( -- n ) Read character | -| t | ( n -- ) Print character | -| j | ( -- ) Unconditional branch. | -| J | ( a -- ) Jump if a == 0. | +| code | name | semantics | +|:----:|:--------:|:-----------------------------------------:| +| Q | quit | ( -- ) Exit the process | +| C | cell | ( -- n ) The size of Cells | +| h | here | ( -- addr ) The address of 'here' cell | +| l | latest | ( -- addr ) The address of 'latest' cell | +| k | key | ( -- n ) Read character | +| t | type | ( n -- ) Print character | +| j | jump | ( -- ) Unconditional branch. | +| J | 0jump | ( a -- ) Jump if a == 0. | +| f | find | ( c -- ) Find CFA of word 'c' | diff --git a/planck.xxd b/planck.xxd index 37dc948..037b280 100644 --- a/planck.xxd +++ b/planck.xxd @@ -6,12 +6,12 @@ 00000028: 3400 2000 0100 0000 e_ehsize,e_phentsize,e_phnum,e_shentsize 00000030: 0000 0000 0100 0000 e_shnum,e_shstrndx, PT_LOAD 00000038: 0000 0000 0080 0408 p_offset,p_vaddr=0x08048000 -00000040: 0000 0000 bd01 0000 p_paddr,p_filesz +00000040: 0000 0000 f001 0000 p_paddr,p_filesz 00000048: 0000 0008 0700 0000 p_memsz(128MB),PF_X|PF_W|PF_R 00000050: 0010 0000 0200 0000 p_align, -00000058: 0300 0000 4881 0408 , (5c: key) -00000060: b081 0408 f8ff ffff (60: jump if zero) (64: -8) -00000068: 8880 0408 0000 0000 (68: quit) (6c: 0) +00000058: c081 0408 4881 0408 , (5c: key) +00000060: c881 0408 8880 0408 (60: find) (64: quit) +00000068: 8880 0408 0000 0000 (68: 0) (6c: 0) 00000070: be5c 8004 08bd 0080 (70: movl $interpreter,%esi) (75: movl $0x10048000,%ebp) 00000078: 0410 adff 2000 0000 (7a: next) 00000080: 0000 0000 0151 0000 "Q" quit @@ -42,3 +42,9 @@ 000001a8: 9081 0408 014a 0000 "J" jump if zero 000001b0: b481 0408 5885 c074 popl %eax; test %eax,%eax;je 19c(-29) 000001b8: e3ad adff 2000 0000 lodsl; next; +000001c0: a881 0408 0166 0000 "f" find +000001c8: cc81 0408 8a24 24b0 movb (%esp),%ah;movb $1,%al; +000001d0: 018b 0d58 8004 088b movl latest,%ecx;<1>movl 4(%ecx),%ebx; +000001d8: 5904 6639 c374 048b cmpw %ax,%bx;je 2f;movl (%ecx),%ecx +000001e0: 09eb f483 c108 890c jmp 1b(-12);<2>addl $8,%ecx;movl %ecx,(%esp) +000001e8: 24ad ff20 0000 0000 next;