Jump to content
IGNORED

fbForth—TI Forth with File-based Block I/O [Post #1 UPDATED: 06/09/2023]


Lee Stewart

Recommended Posts

Looks good, though the first paragraph advert the E1 heading is confusing to me. It appears to contradict the heading. Might just be me!

 

How's this?:

 

Descriptions of words appearing in the comments here that are part of fbForth may be found in Appendix D The fbForth Glossary.

 

...lee

Edited by Lee Stewart
Link to comment
Share on other sites

 

In fact, you might even go as far as to say "I'm flabbergasted!"

 

Okay folks, challenge for the week: You MUST use flabbergasted in at least one conversation per day for this week. Game on!

 

What can I say?—I'm nonplussed!

 

...lee

Edited by Lee Stewart
Link to comment
Share on other sites

I know everyone's just waiting for this with bated breath <not>, so I will post Appendix N "TMS9900 Assembly Source Code for fbForth" later this afternoon.

 

I will make another proof-reading pass through the entire fbForth 1.0 manual, take into consideration any suggestions posted here and then post the complete manual. This will not take me more than a few days, so hurry up with your suggestions! :P

 

...lee

Link to comment
Share on other sites

While proofing the entire fbForth 1.0 manual, I realized that the Forth words listed in each section of Chapter 2 "Getting Started" are not in alphabetical order. The original TI Forth manual had them unsorted, as well. I believe they were loosely in a usage order; but, the lists are so short that it probably doesn't matter. Considering that the word lists at the beginning of each chapter are in column-primary alphabetical order (actually ASCII order), I wonder whether I should sort the lists in Chapter 2 just for aesthetics. Any opinions either way?

 

...lee

Link to comment
Share on other sites

While attempting to flesh out the explanation of XMLLNK in Chapter 5 of the fbForth 1.0 manual, it occurred to me that the explanation in the E/A manual, page 258 that follows is not precisely accurate:

*

You may also use the XMLLNK utility to branch to an address and start executing
there.  In this case, the DATA instruction is the address to which you wish to
branch.  The first bit of the word must be on, so the address may be from >8000
through >FFFF. 

*

An address of exactly 8000h, though not at all likely, would get past the test in line 8 below (code from fbForth ALC source that duplicates the corresponding E/A utility):

*

*      LINK TO SYSTEM XML UTILITIES
*
XMLENT MOV  *R14+,@GPLWS+2    Get argument
       LWPI GPLWS             Select GPL workspace
       MOV  R11,@UTILWS+22    Save GPL return address
       MOV  R1,R2             Make a copy of argument
       CI   R1,>8000          Direct address in ALC?
       JH   XML30             We have the address
       SRL  R1,12
       SLA  R1,1
       SLA  R2,4
       SRL  R2,11
       A    @XMLTAB(R1),R2
       MOV  *R2,R2
XML30  BL   *R2
       LWPI UTILWS            GET BACK TO RIGHT WS
       MOV  R11,@GPLWS+22     Restore GPL return address
       RTWP
 

*

The result of such code would be an attempt to execute code at the address pointed to by 6030h! :-o The test should be JHE XML30 or line 7 should be CI R1,>7FFF.

 

Does anyone think it's worth changing?

 

@Willsy? @jacquesg? @Tursi? @InsaneMultitasker? @matthew180? @Vorticon? ? @senior_falcon? @apersson850? @Stuart? @acadiel? @arcadeshopper? @OLD CS1? @mizapf? @TheMole?

 

...lee

Edited by Lee Stewart
Link to comment
Share on other sites

Even though it specifically states you should have familiarity I'm using this manual to learn about Forth from scratch. This work is appreciated by more than regular TI users :)

 

Thank you, Sir! :)

 

Please, let me know of any suggestions you may have to make it better.

 

...lee

  • Like 1
Link to comment
Share on other sites

I'm working on Chapter 9 "The fbForth 9900 Assembler" and it occurred to me that I should add to the Assembler the aliases corresponding to fbForth's THEN (for ENDIF ) and END (for UNTIL ), namely, THEN, (for ENDIF, ) and END, (for UNTIL, ). Because they are all immediate words, I think the following should work. @Willsy? Other Forthers?

*

:  THEN,  [COMPILE]  ENDIF,  ;   IMMEDIATE
:  END,  [COMPILE]  UNTIL,  ;   IMMEDIATE

*

or is the IMMEDIATE not necessary?—the originals have it.

 

...lee

Link to comment
Share on other sites

They certainly do need to be immediate. The names of the words end in a comma, which, by convention, means they "do something" (in practice, they lay down some machine code) as they are encountered. So yep, they need to be immediate.

 

I do wonder if they are necessary though. END, as a synonym for UNTIL, doesn't work in my book! UNTIL, (to me) is clear. END, seems much more ambiguous.

 

You might get more mileage out of adding SYNONYM to the kernal, if you can squeeze it in. Then users could define it themselves with:

 

SYNONYM THEN, ENDIF,

etc.

 

TF has SYNONYM, but it's not in the kernal. It's defined thusly; probably only minor mods required for fbForth:

--BLOCK-00046---------
: SYNONYM
  CREATE  BL WORD FIND DUP IF
    SWAP , IMMEDIATE 1+ IF
      DOES> @ EXECUTE
    ELSE
      DOES> STATE @ IF
        @ ,
      ELSE
        @ EXECUTE
      THEN
    THEN
  ELSE
    TRUE ABORT" Word not found"
  THEN ;

The above code can cope with synonyms of immediate words. Note that all synonyms themselves are immediate.

 

:thumbsup:

 

I think the only changes required for fbForth would be at the top of the code, around FIND.

 

Here's how mine works:


CREATE \ create the synonym

BL WORD FIND DUP IF \ find the target word in the dictionary
SWAP , \ compile the CFA of the target word into the synonyms' PFA

IMMEDIATE \ make the newly created synonym immediate

1+ IF \ check to see if the target word was an immediate word

FIND probably has a different stack effect in TF to fbF. Here's TF's definition for FIND.

 

Enjoy :grin:

Edited by Willsy
Link to comment
Share on other sites

@Willsy...

 

Much food for thought—thanks!

 

I agree with you about END ; but, I need to keep it for compatibility with TI Forth. However, END, was never part of TI Forth's TMS9900 Assembler, so the only word I should consider for synonym status is THEN, .

 

I don't know that I will implement SYNONYM ; but, I certainly will attempt to understand your definition with my old brain. In perusing the Forth standards documents from Forth-79 to ANSI-draft Forth 2012 RC1), the first (and only) time SYNONYM appears is in the 2012 draft. The one troubling comment is "An ambiguous conditions [sic] exists if oldname can not be found or IMMEDIATE is applied to newname." What I may do is to wait until I try to hoist fbForth into cartridge space and, if I put the Assembler there (the 64KB Guidry cartridge board makes that possible :D ), THEN, will simply branch to the execution code for ENDIF, and it will be as if ENDIF, had been the word entered, i.e., no return to the code for THEN, . Of course, I could just repeat the definition for ENDIF, with all that extra room. :P

 

...lee

Edited by Lee Stewart
Link to comment
Share on other sites

... TF has SYNONYM, but it's not in the kernal. It's defined thusly; probably only minor mods required for fbForth:

--BLOCK-00046---------
: SYNONYM
  CREATE  BL WORD FIND DUP IF
    SWAP , IMMEDIATE 1+ IF
      DOES> @ EXECUTE
    ELSE
      DOES> STATE @ IF
        @ ,
      ELSE
        @ EXECUTE
      THEN
    THEN
  ELSE
    TRUE ABORT" Word not found"
  THEN ;

...

 

Here it is in fbForth:

*

HEX
: SYNONYM
  <BUILDS  -FIND IF             
    SWAP CFA , IMMEDIATE 40 AND IF
      DOES> @ EXECUTE
    ELSE
      DOES> STATE @ IF
        @ ,
      ELSE
        @ EXECUTE
      THEN
    THEN
  ELSE
    ." Word not found" ABORT
  THEN ;

*

How it works in fbForth:

 

<BUILDS { create the synonym }

-FIND IF { find the target word in dictionary; not found leaves only false; found leaves PFA, length-byte and true }

SWAP CFA , { compile the CFA of the target word into the synonym's PFA }

IMMEDIATE { make the newly created synonym immediate }

40 AND IF { check to see if the target word was an immediate word }

{ 40h is the value of a set precedence bit (if set, the word is immediate) and is part of the length-byte }

...

." Word not found" ABORT { there is no ABORT" in fbForth; ABORT is the same in both fbF and TF }

...lee

Edited by Lee Stewart
Link to comment
Share on other sites

OK—this works:

*

HEX
: SYNONYM  ( fbForth)
  <BUILDS -FIND IF             
    SWAP CFA , IMMEDIATE 40 AND IF
      DOES> @ EXECUTE
    ELSE
      DOES> STATE @ IF
        @ ,
      ELSE
        @ EXECUTE
      THEN
    THEN
  ELSE
    ." Word not found" 
    LATEST 2- DUP @ CURRENT @ !
    DP !
    ABORT
  THEN ; 

*

It appears to do what I intend; but, it should probably be tested a bit more.

 

Here's what the additional code in lines 15 and 16 does:

 

LATEST { gets the NFA (name field address) of the last defined word }

2- DUP { backs up 2 bytes to the LFA (label field address—points to previous word's NFA) and duplicates it }

@ { gets the NFA of the previous latest word in the current vocabulary }

CURRENT @ { gets the current vocabulary's pointer to the latest word }

! { stores the previous latest word's NFA in the current vocabulary's latest-word pointer }

DP ! { stores the LFA of the failed word (the old HERE ) in the dictionary pointer to become the new HERE }

 

...lee

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...