Jump to content

Photo

fbForth—TI Forth with File-based Block I/O [Post #1 UPDATED: 08/20/2017]

fbForth Forth TI Forth

1396 replies to this topic

#1376 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Mon Apr 17, 2017 7:54 AM

And if you are taking extra space for 2 INCT instructions, ADDI is faster no?

 

B

 

At 14 clock cycles and 4 memory accesses, indeed it is!

 

...lee



#1377 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Sat Apr 22, 2017 8:28 PM

I have updated post #1 with the latest FBLOCKS file in ZIP format.  It now includes the Compact Flash Utilities, CF? , CFMOUNT , CFVOLS discussed a few posts back.

 

I am still working on updating the manual and still hoping to have that done by Fest West time—we shall see.  |:)

 

...lee



#1378 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Sat Apr 29, 2017 9:29 PM

The April 28, 2017 update to fbForth 2.0: A File-Based Cartridge Implementation of TI Forth (the manual) has been announced at Fest West 2017 and is posted to post #1 of this thread.  It includes all changes since the June 20, 2015 revision.  It is up to date as of fbForth 2.0:9 and FBLOCKS 19APR2017.

 

...lee



#1379 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Sun May 28, 2017 12:41 PM

I am in the process of getting the manual, fbForth 2.0: A File-Based Cartridge Implementation of TI Forth, in shape to publish as a book that will be available on Amazon.com.  My knee surgery (successful and recovering fast!) has slowed this down considerably.

 

While reviewing Chapter 18 “Signed Integer Division”, I noticed several instances of “signed integer division” that should be “symmetric integer division”.  I don't think I will post a revised copy of the manual to post #1 until I publish the book.  Both symmetric and floored division are signed, so it should be obvious that “signed integer division” should be “symmetric integer division” where it is compared to “floored integer division”.

 

...lee



#1380 apersson850 OFFLINE  

apersson850

    Moonsweeper

  • 421 posts

Posted Tue May 30, 2017 12:16 PM

I noticed at the beginning of this thread that a Forth verson places "NO" in a lot of words of memory. The UCSD p-system places "NO" at a specific memory location when you halt it, to prevent it from starting the next time you warm start your computer.



#1381 TheBF OFFLINE  

TheBF

    Moonsweeper

  • 319 posts
  • Location:The Great White North

Posted Thu Jun 8, 2017 3:54 PM

I noticed at the beginning of this thread that a Forth verson places "NO" in a lot of words of memory. The UCSD p-system places "NO" at a specific memory location when you halt it, to prevent it from starting the next time you warm start your computer.

 

By NO do you mean  no-OP instruction?

 

Which Forth system were you looking at?

 

I am wondering if you were looking at threaded code that is just the same numeric value as 'NO'. 

There is not inherent reason I can think of for adding NOPs to a Forth system.

 

BF



#1382 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Thu Jun 8, 2017 9:44 PM

By NO do you mean  no-OP instruction?

 

Which Forth system were you looking at?

 

I am wondering if you were looking at threaded code that is just the same numeric value as 'NO'. 

There is not inherent reason I can think of for adding NOPs to a Forth system.

 

BF

 

Anders' (apersson850) observation is from TI Forth's definition of MON ("monitor"), the functional equivalent of FCTN+=, which performs a soft system reset of the TI-99/4A.  The code fills the lower 8 KiB of expansion RAM with the ASCII code for the capital letters “NO” or 4E4Fh.  It effectively fills low RAM with nonsense code.  The TI Forth Assembler for MON follows:

 

HEX
CODE MON
   0 4E4F LI, 
   1 2000 LI,
   BEGIN,
      0 1 *?+ MOV,
      1 4000 CI,
   EQ UNTIL,
   0 @() BLWP,

 

[EDIT]
 
Note that the code above does not end with NEXT, (as it normally should to return to the Forth interpreter) because the last instruction never returns to Forth.
 
In the interest of clarity for those who are unfamiliar with TI Forth, the equivalent fbForth code is
 
HEX
ASM:  MON
   R0 4E4F LI, 
   R1 2000 LI,
   BEGIN,
      R0 *R1+ MOV,
      R1 4000 CI,
   EQ UNTIL,
   0 @() BLWP,
 
The above has no terminating ;ASM for the reason already cited.
 
The actual fbForth code for MON only clears the ISR hook before branching to the console's startup code (also, no terminating ;ASM ):
 
ASM:  MON
   83C4 CLR,
   0 @() BLWP,
 
[/EDIT]
 

...lee



#1383 apersson850 OFFLINE  

apersson850

    Moonsweeper

  • 421 posts

Posted Fri Jun 9, 2017 2:16 AM

Yes, that's what I referred to. I associated this with a similar behavior in the UCSD p-system. Normally, when you start up the TI 99/4A, and have an active p-code card in the machine, the p-code card will never return control to the machine after executing it's power up routine. That's why they gave the p-code card CRU base address >1F00, so that it would always be the last one to run.

 

But if you let the p-code card start, then stop it by the Halt instruction, it will load "NO" in a certain memory location in 8 K RAM. If you then reboot the 99/4A, the p-code card will find "NO" at this location and then return from the power up routine, without taking over the console.

 

Back when I used the 99/4A a lot, I knew the correct CALL LOAD(xxxx,78,79) from BASIC to disable the p-system, but I don't remember the address any longer. The p-system only stores "NO" in one place, to prevent a start.

 

This has nothing to do with the opcode for JMP 0, sometimes called NOP.



#1384 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Mon Jul 17, 2017 9:45 AM

Not that I really want to suggest that anyone not use the structured Assembler constructs detailed in Sections 9.6 – 9.8 of the fbForth 2.0 Manual (inherited from the TI Forth Manual), but Chapter 9 includes Forth definitions the TMS 9900 Assembler jump instructions ( JMP, , JEQ, , ... ) and I am considering showing how to use them if someone insists or is just curious.
 
The defining word for JMP, , JEQ, , ... is
 
HEX  : DOP <BUILDS , DOES> @ SWAP 00FF AND OR , ;
 
and, JEQ, is defined as follows:
 
HEX  1300 DOP JEQ,
 
which expects a word offset of -128 – +127—see the ANDing of the offset with >00FF in the definition of defining word DOP above.
 
That is straightforward enough, but I would like to suggest a way to use labels and have not yet figured that out
 
Any ideas?
 
...lee


#1385 TheBF OFFLINE  

TheBF

    Moonsweeper

  • 319 posts
  • Location:The Great White North

Posted Mon Jul 17, 2017 1:25 PM

For labels I stole an idea from Win32Forth Assembler. It was an older version. Not sure if it still works this way.

It creates pre-defined labels. It's kinda complicated, but it works with one caveat.

Forward jumps can only go to one label.  ie for each forward jump, you must use a separate label.

It could be fixed with a stack but I did not get to it yet.

 

Notes:

1. the ]ASMerr stuff inside IF statements could be replaced with ABORT" .  

2. CODE words need to start by erasing the jump-table. (CLR-JMPTABLE word)

3. THERE can be replaced with HERE.  THERE is my word for "target" HERE for my cross-compiler

 

As noted in the comments, I also create labels in this assembler which are just constants that record the dictionary pointer.

The labels are used by B BLWP and BL.

 

It could use a re-write so that the labels would work with the jump instructions. That would require a little word and then all

jumps would have to be PREFIX because they would have to parse the label string.  

 

Hope this is useful.

 

Spoiler


#1386 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Mon Jul 17, 2017 10:21 PM

H-m-m-m...Thanks for that, TheBF, but I really do think it is far better to use the structured Assembler constructs:

 

IF, … THEN,
IF, … ELSE, … THEN,
BEGIN, … UNTIL,
BEGIN, … AGAIN,
BEGIN, … WHILE, … REPEAT,
 

rather than the branch and jump instructions,

 

B, BL, BLWP, JMP, JNE, JGT, JLT, JLE, JL, JHE, JH, JLT, JGT, JOC, JEQ, JNO, JOP, JNC, JNO, JOP,

 

because Forth words should be short routines and the structured constructs do not require the difficult-to-manage labels as do the branch and jump instructions.  Furthermore, the structured constructs are easier to follow.

 

That said, I think I will work out some explanation of the branch and jump instructions because they are, after all, defined and I think it a disservice to Forth programmers to mention them in Chapter 9 without comment of any kind as was done by the TI Forth developers and, consequently, by me in fbForth.

 

...lee



#1387 TheBF OFFLINE  

TheBF

    Moonsweeper

  • 319 posts
  • Location:The Great White North

Posted Tue Jul 18, 2017 7:32 AM

Ah I see now that I misunderstood your needs.  You want to document them, not actually use them.

 

Then I might suggest that you simply show how the offset for a jump instruction is calculated and then show a definition for something like my +$$ word so they could see it in action. (?)

 

Just my 2 cents Canadian  ( that's only worth 1.58 cents USD these days) :-)

 

 

B



#1388 Willsy OFFLINE  

Willsy

    River Patroller

  • 3,012 posts
  • Location:Uzbekistan (no, really!)

Posted Tue Jul 18, 2017 1:36 PM

Maybe sections 6 and 7 of the TF Assembler manual might provide inspiration?

 

Looking at it now, some years after I wrote it, I think I could write a better manual. :?



#1389 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Tue Jul 18, 2017 8:59 PM

Maybe sections 6 and 7 of the TF Assembler manual might provide inspiration?

 

Looking at it now, some years after I wrote it, I think I could write a better manual. :?

 

Nope.  I think I have what's discussed there pretty well covered in the fbForth 2.0 Manual,  Willsy,

 

Well...I should not be so quick to cast aside your suggestion to look for inspiration there.  I was actually thinking of doing something for the jump instructions similar to how the structured constructs manage their jumps, but that would not work for the branch instructions.

 

...lee



#1390 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Sat Jul 22, 2017 8:05 AM

In the manual, I have included information on how to use the Forth Assembler jump instructions, which work differently in the Forth Assembler from how they work in the Editor/Assembler version.  I discourage their use, but tell you how to use them anyway.  Section 9.9 is the new section.

 

Also, note the corrected jump tokens table in Section 9.7.

 

Feel free to make suggestions/corrections in the attached Chapter 9:  Attached File  fbForth_2.0_Manual_Chapter9_20170722.pdf   203.21KB   6 downloads

 

...lee



#1391 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Thu Jul 27, 2017 8:07 AM

I am in the final stages of publishing my manual, fbForth 2.0: A File-Based Cartridge Implementation of TI Forth.  It should be available on CreateSpace.com and Amazon.com in 2 – 3 weeks.  I will also bring a few copies to the Chicago Faire for interested attendees.  A public “Thank you!” to jedimatt42 for editing assistance and proofreading.

 

...lee



#1392 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Sat Aug 12, 2017 11:28 PM

FYI—I just discovered a bug in FRAC in the resident dictionary!  Its use will crash the system.  The word is supposed to yield the fractional part of a floating point (FP) number.  Back when I brought the FP library into the same Assembly space as the rest of fbForth 2.0, after reducing the number of labels that made it possible, I had to resolve at least one label conflict (I’m sure there were more).  Unfortunately, I did not change the reference in FRAC to the new label, so it jumps into the weeds and blows up!  I will fix it in the next build.  Meanwhile, the following code will work nicely (note Forth’s response is underlined):

 

: FRAC  ( f1 --- f2 )  FDUP TRUNC F- ;  FRAC isn't unique  ok:0

 

...lee



#1393 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Sun Aug 20, 2017 2:45 PM

The manual is published!  See updated post #1 as well as my new website for fbForth in my signature below.

 

...lee

 

PS:  I will have copies at the Faire in Evanston, IL for a little less, if you want to wait.  :)



#1394 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Sat Aug 26, 2017 6:41 PM

Here are updated, high-level Forth versions of the HCHAR and VCHAR words.   They are what I used to model the ALC versions for the next build of fbForth 2.0:

 

Spoiler
 

I will post fbForth Assembler and machine code versions in a day or two for those who might want to include them in FBLOCKS for fbForth 2.0:9—or just want to see how they perform.

 

The ALC version of VCHAR inlines the code for VSBW and rivals the speed of the ALC version of HCHAR !

 

...lee



#1395 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Mon Aug 28, 2017 7:25 AM

Here are the promised ALC versions of VCHAR and HCHAR :

 

Spoiler

 

To compile these definitions, you will need to load the TMS9900 Assembler from FBLOCKS.  I will post the machine code versions in a bit.  The machine code versions will not need the assembler.

 

...lee



#1396 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Mon Aug 28, 2017 8:16 AM

And—Here are the machine code versions of VCHAR and HCHAR :

HEX
CODE: VCHAR   ( x y cnt ch --- )
   C079 06C1 C0B9 C1B9 C039 C160 36E8 3985 A007 C1A0 36EA A006
   C120 36EC C1C4 61C6 0607 C0C5 A0C6 8100 1105 0649 04D9 06A0
   39B4 6912 0300 0000 0260 4000 06C0 D800 8C02 06C0 D800 8C02
   D801 8C00 0240 3FFF A005 8100 1104 6007 80C0 1601 C006 0602
   16EB
;CODE

CODE: HCHAR   ( x y cnt ch --- )
   C039 06C0 C139 C079 3860 36E8 A0B9 C1A0 36EA A086 C160 36EC
   C1C5 61C6 8107 1501 C107 8142 1105 0649 04D9 06A0 39B4 6912
   6142 0300 0000 8107 1501 C107 C044 1501 1008 6105 1101 C045
   06A0 31F0 C086 C147 10F5
;CODE
DECIMAL 

These were produced with ASM>CODE (see the manual at fbforth.stewkitt.com) and will only work in fbForth 2.0:9.  If you have an earlier version of fbForth 2.0, you can produce your own version with ASM>CODE after first loading the TMS9900 Assembler and ASM>CODE from FBLOCKS and compiling the ALC words from the previous post modified with corrected addresses for BLA2F and FILL1.  I can supply those addresses if you tell me what version of fbForth 2.0 you have.

 

...lee



#1397 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • Topic Starter
  • 3,341 posts
  • Location:Silver Run, Maryland

Posted Wed Oct 11, 2017 7:58 PM

OK...I have decided to release fbForth 2.0:10 at the Chicago Faire on Saturday.  It will include the fixes for FRAC , HCHAR and VCHAR discussed in the last several posts.  Bring your cartridges for re-burning or swapping EPROMs FOC.

 

...lee







Also tagged with one or more of these keywords: fbForth, Forth, TI Forth

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users