6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun May 05, 2024 5:52 pm

All times are UTC




Post new topic Reply to topic  [ 264 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 18  Next
Author Message
PostPosted: Wed Jan 28, 2015 2:06 pm 
Offline

Joined: Sun Jul 28, 2013 12:59 am
Posts: 235
LEAVE seems fairly obvious to me for some reason.

Given an implementation of DO as:
Code:
: *do 2>R ;
: DO [COMPILE] *do 0 HERE ; IMMEDIATE

And LEAVE as:
Code:
: 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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 28, 2015 9:32 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1928
Location: Sacramento, CA, USA
theGSman wrote:
... 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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 28, 2015 10:12 pm 
Offline

Joined: Mon Jan 26, 2015 6:19 am
Posts: 85
nyef wrote:
Code:
: 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.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 28, 2015 10:22 pm 
Offline

Joined: Mon Jan 26, 2015 6:19 am
Posts: 85
barrym95838 wrote:
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 29, 2015 4:57 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8432
Location: Southern California
Quote:
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.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 09, 2015 10:42 pm 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
(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.)


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 10, 2015 12:46 am 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
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:
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Feb 10, 2015 6:26 am 
Offline

Joined: Mon Jan 26, 2015 6:19 am
Posts: 85
scotws wrote:
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:
: FACTORIAL ( n -- n! ) RECURSIVE
    DUP 1 <= IF EXIT THEN
    DUP 1 - FACTORIAL *
;


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 11, 2015 3:04 am 
Offline

Joined: Sat Dec 26, 2009 2:15 am
Posts: 39
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


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 16, 2015 3:21 pm 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
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.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 30, 2016 1:51 am 
Offline

Joined: Wed Jan 08, 2014 3:31 pm
Posts: 575
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.


Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 02, 2016 9:28 pm 
Offline

Joined: Wed Jan 08, 2014 3:31 pm
Posts: 575
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.


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 03, 2016 9:16 am 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
Great to hear, I'm glad it's working for you! Please let me know if you have any suggestions ...


Top
 Profile  
Reply with quote  
PostPosted: Sat Nov 18, 2017 3:29 pm 
Offline

Joined: Thu Mar 03, 2011 5:56 pm
Posts: 277
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.)


Top
 Profile  
Reply with quote  
PostPosted: Fri Nov 24, 2017 2:48 pm 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 264 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 18  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: