Page 5 of 19
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Wed Jan 28, 2015 2:06 pm
by nyef
LEAVE seems fairly obvious to me for some reason.
Given an implementation of DO as:
Code: Select all
: *do 2>R ;
: DO [COMPILE] *do 0 HERE ; IMMEDIATE
And LEAVE as:
Code: Select all
: LEAVE [COMPILE] UNLOOP >R >R AHEAD R> 1+ R> ; IMMEDIATE;
You then have a point when compiling LOOP and +LOOP where you have ( orig1 .. orign n ) on the data stack (each orig from calling AHEAD) and need to invoke THEN n times to resolve each orig... Which you basically have to do for END-CASE anyway. There is sample code in section A.3.2.3.2 of the ANS standard for the CASE-related bits.
This is an untested implementation sketch: My current Forth implementation contains neither DO .. LOOP nor CASE .. END-CASE at this point.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Wed Jan 28, 2015 9:32 pm
by barrym95838
... Cleaning up the stack is a common necessity at the end of a word.
I suppose it could be argued that "better" factoring would make that necessity much less common, but I can see your point, even through the eyes of a n00b.
Mike B.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Wed Jan 28, 2015 10:12 pm
by theGSman
Code: Select all
: LEAVE [COMPILE] UNLOOP >R >R AHEAD R> 1+ R> ; IMMEDIATE;
It seems to me that a SWAP would also be in order since the usual context of this word is IF LEAVE THEN and we don't want the stack to be messed up when coding the THEN statement.
I still don't see how it would work if you were using LEAVE from within a nested IF statement.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Wed Jan 28, 2015 10:22 pm
by theGSman
I suppose it could be argued that "better" factoring would make that necessity much less common, but I can see your point, even through the eyes of a n00b.
Factoring may reduce the number of stack items you have to handle at any one time but it is unlikely to change the cleanup requirements at the end of a word.
It is true however that you can keep stack cleanup to a minimum if you code carefully.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Thu Jan 29, 2015 4:57 am
by GARTHWILSON
I still don't see how it would work if you were using LEAVE from within a nested IF statement.
Compiler security checking would have to be left out. I do leave it out, and I'm just careful, and have never had a problem.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Mon Feb 09, 2015 10:42 pm
by scotws
(In case somebody is reading this thread and wondering where the rest of the discussion went: How to do DO/LEAVE/IF etc was handled in
viewtopic.php?f=9&t=3176 with code.)
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Tue Feb 10, 2015 12:46 am
by scotws
With the addition of RECURSE, I've decided to consider Tali Forth "feature complete" and now in BETA. Yippie! This means no more new words for now, because we start optimizing and hunting bugs.
The "frozen" word set is:
Code: Select all
ACTION-OF IS REPEAT WHILE UNTIL ELSE IF WORDS DROP 2DROP ! @ ? 2R> 2R@ 2>R >R R> R@ OVER 2OVER DUP ?DUP 2DUP SWAP 2SWAP NIP TUCK ROT -ROT PICK DEPTH 1- 1+ FALSE TRUE BRANCH (BRANCH) 0BRANCH (0BRANCH) BEGIN AGAIN THEN DO ?DO (DO) (?DO) I J UNLOOP LOOP +LOOP (+LOOP) LEAVE RECURSE ABS DABS + - * / */ */MOD UM* M* UM/MOD UD/MOD SM/REM FM/MOD MOD /MOD M+ AND OR XOR INVERT NEGATE DNEGATE MAX MIN LSHIFT RSHIFT S>D D>S D+ D- <# # #S HOLD SIGN #> U. U.R UD. . .R D. D.R 2 1 0 < = > 0= 0< COUNT >IN TYPE EMIT CHAR [CHAR] TOUPPER KEY BASE HERE PAD UNUSED MARKER ERASE FILL CELL+ CELLS CHAR+ CHARS C, C! C@ CMOVE CMOVE> MOVE ALIGN ALIGNED ALLOT , DEFER@ DEFER! DEFER ' ['] >BODY >NAME EXECUTE EVALUATE STATE COMPILE, : ; ] [ POSTPONE IMMEDIATE COMPILE-ONLY NATIVE-COMPILE CREATE DOES> (DOES>) VARIABLE 2VARIABLE TO VALUE CONSTANT +! SOURCE DECIMAL HEX BINARY DIGIT>NUMBER NUMBER >NUMBER BL CR SPACE SPACES AT-XY PAGE BOLD REGULAR BELL ." S" .( ( \ /STRING -TRAILING FIND ACCEPT PARSE PARSE-NAME WORD .S SEE DUMP (ABORT") ABORT" QUIT ABORT LITERAL (LITERAL) COLD BYE
GitHub has the code to browse at
https://github.com/scotws/TaliForth , and the ophis.bin file should run with py65 as described in README.txt . As always, I'm very grateful for any suggestions, corrections, and feedback.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Tue Feb 10, 2015 6:26 am
by theGSman
With the addition of RECURSE, ..............
RECURSIVEness was the easiest thing for me to do.
While the current word is being defined, a "smudge" bit is set in the name so that the word wont be found during a word search. Thus, if another word of the same name exists, it will be found instead.
To make the current word that is being defined recursive, all I need is a compiler word named RECURSIVE that removes the smudge bit. Interestingly, RECURSIVE can be placed anywhere within the current word prior to the word being called although placing it just after the name of the word aids readability.
Example:
Code: Select all
: FACTORIAL ( n -- n! ) RECURSIVE
DUP 1 <= IF EXIT THEN
DUP 1 - FACTORIAL *
;
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Wed Feb 11, 2015 3:04 am
by mstram
As you know Scott, I just got Taliforth running on py65mon, thanks to some very quick bug fixes by the py65mon author.
I was thinking of trying to get it running on the Vice emulator.
Are there any "challenges" with that ?
And if not, I'm wondering why you didn't target that emulator from the beginning ?
Seems to me to be much more "feature-full" than py65mon.
Mike
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Mon Feb 16, 2015 3:21 pm
by scotws
I wasn't looking for something full-featured, I was looking for something that was simple to use and that would work from the command line in OS X and Linux. Also, the web page of Vice said something about "last release 2012" (still does, see
http://vice-emu.sourceforge.net/ ) so I figured it wasn't being developed any more.
Py65mon has been fantastic for me, except for the part with the magic numbers for the getc and putc ports. I still don't understand why that is not in a config file or a value from the command line.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Thu Jun 30, 2016 1:51 am
by Martin_H
I finally got around to installing the ophis assembler and built Tali Forth. I then adjusted the RAM size to fit my machine, and then changed the 6522 VIA address. I have a 6551 ACIA instead of a 6850 ACIA UART, so that looks like the biggest source of incompatibility.
Quick question. Is the output format of Ophis in the same format as the output of the TASS assembler? If so then my home brew EEPROM programmer is compatible.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Sat Jul 02, 2016 9:28 pm
by Martin_H
I was able to change the serial code to use the 6551 ACIA, which only took me about an hour. It wasn't much work, but I double checked everything because I wanted the best shot of getting it to work first time. I then tried the Ophis bin file with my home brew EEPROM programmer and it is compatible with Intel hex file format. So I was able to use my home brew EEPROM programmer.
I then put the EEPROM into my 6502 machine, turned it on and was greeted with the Forth ok prompt. I typed 1 2 + . and it output 3, so success. There's only one small problem with each new line being indented from the last. I'll need to figure that out, but that seems small.
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Sun Jul 03, 2016 9:16 am
by scotws
Great to hear, I'm glad it's working for you! Please let me know if you have any suggestions ...
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Sat Nov 18, 2017 3:29 pm
by rwiker
Since scotws in another thread asked for suggestions for the rewrite of Tali Forth:
1) Move the handling of multiple I/O channels out from the common sources (Tali-Forth.asm), and into the platform-dependent part (Tali-Kernel-<platform>.asm). That will remove one of the few remaining platform dependencies from Tali-Forth.asm.
2) Add an I/O driver for reading characters from memory. This could then be used for reading/parsing/compiling the high-level Forth words from memory at startup in a slightly less complex way than the current implementation. (Possibly using a newline-separated sequence of definitions, with a "bye" at the end to close the channel and return to the initalization code.)
Re: Introducing Tali Forth for the 65c02 (ALPHA)
Posted: Fri Nov 24, 2017 2:48 pm
by scotws
Thanks for both suggestions. Suggestion 2 is already realized in Liara Forth (65816), and works a lot better. Suggestion 1 is a major reason I want to rewrite it - again, Liara Forth does this so much better in an ANSI fashion.
I'll be opening a new repository for work on Tali 2 in the next couple of days I hope.