http://www.flickr.com/photos/chitselb/s ... 696682160/
Alas, I couldn't find Forth for the PET anywhere on the Internet! Does anybody know where there is one?
Plenty of Forth for the C=64 though. So I got copies of volksForth, Blazin' Forth (my old favorite), and figForth and began to roll my own (PETTIL, for Personal Electronics Transactor Threaded Interpretive Language, also a play on the surname of the engineer who helped make the 6502 and the PET).
http://volksforth.sourceforge.net/
ftp://ftp.taygeta.com/pub/Forth/Compile ... mmodore64/
The idea here is to learn something new and have some fun creating. For me, the fun is in optimizing for time. After doing way too much further research, I decided to go with a direct threaded model vs. the more typical indirect threaded. I'm storing TOS in a zero page register, using a split parameter stack on zero page, and whatever else I can come up with to make PETTIL the fastest Forth on Commodore 8-bits. I'll be hashing the dictionary to speed up FIND (a simple "XOR all the nybbles of the name field together" 0..15 hash). Any other suggestions are appreciated.
After a few hours of throwing every trick in the book at it, here's my PETTIL NEXT routine
Code: Select all
clocks
0006 85 22 0 3 puta sta tos
0008 A0 01 0 2 next1 ldy #1
000A B1 0F 5 1 next lda (ip),y
000C 85 1D 3 sta w+1
ip = *+1
000E AD FF FF 4 lda $ffff
0011 85 1C 3 sta w
0013 98 2 tya
0014 38 2 sec
0015 65 0F 3 adc ip
0017 85 0F 3 sta ip
0019 B0 03 2 1 bcs t2
w = *+1
001B 4C FF FF 3 t1 jmp $ffff
001E E6 10 0 5 t2 inc ip+1
0020 B0 F9 0 3 bcs t1 ; bra
tos = *
===
30 (best case)
45 (worst case)
Code: Select all
0006 4 8D FA 7A STA $7AFA ; 7-8 is SP
0009 5+ B1 0E LDA ($0E),Y ; <-- best case entry point, assumes Y=1
000b 3 85 1D STA $1D
000d 4 AD 3C 3A LDA $3A3C ; 0e-0f is IP
0010 3 85 1C STA $1C
0012 2 18 CLC
0013 3 A5 0E LDA $0E
0015 2 69 02 ADC #$02
0017 3 85 0E STA $0E
0019 2+ B0 03 BCS $001E
001b 5 6C 90 13 JMP ($1390) ; 1c-1d is W
001e 5 E6 0F INC $0F
0020 3 B0 F9 BCS $001B ; bra