To prepare for the
COMPILE, code that will allow native compiling of words based on their length, I've created a word named
WORDS&SIZES that adds the size of CFA+PFA - a word's "code" in bytes - to the output. The idea here is to be able to provide a threshold value up to words will be compiled in native code (with $0 for "never" and $FFFF for "always"). So far,
COMPILE, only does brutish subroutine compiling, so high-level words are going to be shorter, but far slower, now than later. Still, this is the very first data on word length:
Code: Select all
d.r 39 d. 27 ud.r 27 ud. 15 .r 42 u.r 30 u. 18 */mod 12 */ 18 /mod 12 / 18 fm/mod 72 sm/rem 67 while 15 until 6 repeat 12 else 21 then 9 if 12 .( 11 ( 11 drop 4 dup 4 swap 5 ! 11 @ 4 over 6 bounds 9 digit? 59 >r 7 r> 7 r@ 8 2drop 6 here 6 execute 10 rot 8 -rot 8 nip 2 tuck 8 \ 4 accept 131 , 11 source-id 6 parse-name 100 refill 50 find-name 86 0 7 1 7 2 7 number 131 >number 92 true 7 false 7 = 11 <> 11 0= 11 < 19 > 19 0< 11 0> 10 0<> 11 1+ 1 1- 1 + 7 - 10 2* 3 c! 15 c@ 11 c, 13 +! 15 and 6 or 6 xor 6 char 23 invert 5 negate 6 max 18 min 18 ' 27 variable 12 constant 25 depth 14 source 12 >in 7 state 7 abs 8 2dup 10 name>string 16 create 114 does> 12 >body 3 allot 40 : 33 ; 24 compile, 18 begin 6 again 21 branch 6 0branch 6 latestxt 15 latestnt 7 [ 2 ] 5 postpone 53 immediate 8 compile-only 8 literal 17 [char] 6 ['] 6 sliteral 74 s" 17 ." 20 cells 3 evaluate 46 base 7 pad 11 . 30 type 32 .s 71 space 6 spaces 12 bl 7 <# 9 # 26 sign 13 #s 8 hold 13 #> 14 cr 6 name>int 8 ? 6 quit 63 parse 50 abort 71 abort" 28 count 14 um* 94 m* 31 * 7 um/mod 80 ud/mod 27 d+ 17 s>d 15 d>s 4 dnegate 19 dabs 6 page 12 unused 11 hex 5 decimal 5 bell 6 wordsize 18 dump 38 words 60 words&sizes 67 cold 123 bye 3
The formatting sucks, of course, I'll figure something better out later. The words from
DROP to
BYE are hard-coded in the Dictionary, everything after that (that is, at the beginning of this list) is compiled out of high-level Forth code. The RTS instruction is
not included in the tally, because native coding will strip it out.
R> and
>R will be two bytes shorter each because of they'll be a special case in the native compile routine (they're used so often it will be worth it).
Still, some interesting stuff already.
NUMBER is amazingly long at 131 bytes, which is the same size as
ACCEPT that does all kinds of input filtering.
The word
WORDSIZE ( nt -- u ) gives the code size of individual words, so I can experiment on the command line. It's all still very much early days, but the good news is that I can get a feeling for how large stuff is now.