Tachyon V4 "DAWN" - exploring new worlds

167891012»

Comments

  • proplem wrote: »
    Hi there - shouldn't this
    ( 0003 $589E  ok )   -100 25 100 */ .
    1073741799
    
    give -25 ?
    ( 0011 $1A80  ok )   -100 25 * 100 / .
    -25
    
    Well I guess I should rename */ to U*/ but do you need a signed */ or other operations? There are probably a few areas I need to check for correct naming and operation.

    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Brisbane, Australia
  • I saw the */ operator in "Starting Forth" and thought - that fits.
    No need for a hurry - thanks for the quick response
    I Am One With the Forth and the Forth Is With Me
  • Peter JakackiPeter Jakacki Posts: 6,315
    edited May 15 Vote Up0Vote Down
    Re: Revising DO and +LOOP practice - replacing with DOFOR

    Now that I've thrown DO and +LOOP into the trash even though they have never changed in all of Forth history, I find that I have a lot of code that has this practice of "end start" parameters locked into it. However I am testing this and even though it is "better" I still find that I'm getting my poor head around it. One of the main features of the new DOFOR LOOP method is that DOFOR takes a start parameter, a actual loop count, and a index increment that gets added to the start value each loop where normally this is simply the value of one.

    DOFOR doesn't run any faster than the previous loops I had since I use a rather fast branch stack but you really notice the difference in speed when the old +LOOP method is used.
    Here is the old method which times the loop for 1,000,000 (2000000/2) (80MHz)
    ( 0076 $4F0A  ok )   0 2000000 LAP ADO 2 +LOOP LAP .LAP
    176000336 cycles at 80MHz = 2.200sec
    
    So that is 2.2us/loop which is really slow.

    The equivalent DOFOR code (at 96MHz)
    ( 1619 $42BA  ok )   0 1000000 2 LAP DOFOR LOOP LAP .LAP
    48000432 cycles at 96MHz = 500.004ms 
    
    Now each loop executes at 500ns regardless of the loop increment and always executes times the loop count regardless of the increment value.

    Since the loop count controls how times the DOFOR loop executes independently of the increment value it means we can do reverse loops which were very awkward with the conventional DO LOOP arrangement:
    ( 1641 $42BA  ok )   $7F 96 -1 DOFOR I EMIT LOOP
    ~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"! 
    ( 1642 $42BA  ok )
    
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Brisbane, Australia
  • This doesn't append very far with that EXIT as the first word?
    .VER
      Propeller .:.:--TACHYON--:.:. Forth V4.3 DAWN 430170514.0076
    ( 0019 $4198  ok )   .MODULES
    
    MODULES LOADED: 
    3304: EASYFILE.fth        SDHC card + FAT32 Virtual Memory Access File System Layer V1.2 170506-0000 
    1A40: EXTEND.fth          Primary extensions to TACHYON+ kernel  - 170427-2200
    ( 0020 $4198  ok )   
    pub APPEND ( eof -- fsptr )
    	EXIT
    
    \ reimplement - DO NOT ASSUME eof = 0 as in LEN$
    
         eof C!
         FSECT@ DUP 0EXIT DROP				--- exit with false if there is no file opened
         APPEND.BLK ( -- relblk )				--- find the active block to use
         8<< 2* sdbuf LEN$ BLKSIZ MIN +			--- add in offset allowing for a full block as well
    \     FILE@ FSIZE@ + OVER = IF DROP FALSE THEN
         DUP fwrite !
         ;
    
    
  • @D.P - Ahh, you saw that stub. Yes, I may get around to it tonight and put the scanning SDRD back in and all should be good again for 4.3.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Brisbane, Australia
  • Peter JakackiPeter Jakacki Posts: 6,315
    edited May 19 Vote Up0Vote Down
    V4.4 UPDATES

    V4.4 which introduced DOFOR in place of DO, ADO, and +LOOP seems to be working well. The only problem I've had so far is wrestling with some old code that complicated the stack to suit the old DO LOOP arrangement. After conversion it is not so complicated anymore. I wonder why Forth used this arrangement in the first place since I find that I almost invariably use the start index and count method but looping with +LOOP complicated this still.

    Because the loop stack is a separate stack in COG memory it had been implemented as fixed position registers with brute force ripple moves for push and pop. However there is one extra element on the stack for each DOFOR now and the ripple move was becoming too unwieldy so I made it a hybrid stack with the top four elements as fixed registers much the same as the data stack is implemented. The top four elements are: index (I); count (IY); and increment with the next element being the previous index (J). A count of 0 for either FOR or DOFOR will terminate the loop after the first iteration rather than for over 4 billion times which I am pretty sure would not be the intention.

    Also added is 16-bit literals since 15-bit were encoded as a single wordcode but anything was always encoded as three words (PUSH32,highword,lowword).
    There are lots of little enhancements and I still have room left in the cog after all this to enhance it some more.

    For fast I/O work there are the pin mask operators H L and F which will set pins High Low or Float (back to input) by reading a mask off the top of the stack without discarding. This is different from the P2 version that may have been used since the P2 version used PIN to set the mask internally whereas 4.4 just borrows the mask from the stack.

    EASYFILE is also working well on 4.4 so I will fix the APPEND operation in this version first since I am testing it.

    If you are still stuck with V3 just remember that even V4.0 is very old now and V4.4 is the goto version to use IMO. Wordcode being more compact and faster "overall" than bytecode, who woulda thunk it?
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Brisbane, Australia
  • V4.4 UPDATES

    V4.4 which introduced DOFOR in place of DO, ADO, and +LOOP seems to be working well. ...
    Hi Peter - congratulations ro the new minor version!
    As I'm always curious to stay on the bleesing edge but I don't know if that is always welcome to you. You solved a few issues recently which took time on your side.
    Additionaly it could be of advantage to branch v44 into a new folder.
    Best regards,
    Proplem
    I Am One With the Forth and the Forth Is With Me
  • V4 is looking better every day but as an added measure I have introduced an auxiliary stack for those times when you need to push stuff out of the way. Traditionally the return stack was used but in my embedded 24/7 reliability view this should never ever be as this could lead to uncontrolled execution <crash!> if values other than return addresses are left there. So I have used the loop stack with >L and L> but this stack is limited in cog memory so hence the auxiliary stack using >A A> and A@ which should be used for shuffling and even temporary constants via A@.

    The doNEXT address interpreter has been tweaked as well just to give some priority to calls to wordcode so they run a bit faster again. Just remember too that for fast I/O you can use H L and F to control outputs with sub-microsecond resolution, good enough even to bit-bash serial RGB LEDs or 1-wire etc.

    A moment ago I was just fixing up some little bug I had introduced in the filesystem in creating files. Anyway I normally preallocate contiguous sectors when creating a file and so I specify the maximum file size with a number. Just to make it easier I created two small words KB and MB which are nothing more than a left shift operation but very useful. To create a 16MB file just:
    16 MB mk NETLOG.TXT
    or to ASCII wide dump the 1 KB of a file offset 1 MB from the start of the file:
    1 MB 1 KB FS DUMPAW
    ( 0060 $4202  ok )   FOPEN WARPEACE.TXT
    ...opened at 0000.48C0 for 3226652
    
    ( 0061 $4202  ok )   1 MB 1 KB FS DUMPAW
    
    0010.0000:  .down his back..."Why, this one seems..." he began, turning to the assistant..."And how we've been begging, your honor," said th
    0010.0080:  e old soldier, his jaw.quivering. "He's been dead since morning. After all we're men, not.dogs.".."I'll send someone at once. He
    0010.0100:   shall be taken away--taken away at once,".said the assistant hurriedly. "Let us go, your honor.".."Yes, yes, let us go," said R
    0010.0180:  ostov hastily, and lowering his eyes and.shrinking, he tried to pass unnoticed between the rows of reproachful.envious eyes that
    0010.0200:   were fixed upon him, and went out of the room......CHAPTER XVIII..Going along the corridor, the assistant led Rostov to the off
    0010.0280:  icers'.wards, consisting of three rooms, the doors of which stood open. There.were beds in these rooms and the sick and wounded 
    0010.0300:  officers were lying or.sitting on them. Some were walking about the rooms in hospital dressing.gowns. The first person Rostov me
    0010.0380:  t in the officers' ward was a thin.little man with one arm, who was walking about the first room in a.nightcap and hospital dres
    ( 0062 $4202  ok )   16 MB mk NETLOG.TXT
    
    ( 0063 $4202  ok )   ls-l
    
    -rwxrwxrwx 1 502     500        65536 Aug  4  18:01 SCR.ROM
    -rwxrwxrwx 1 502     500      1048576 Dec  2  15:56 SYSLOG.TXT
    -rwxrwxrwx 1 502     500      3226652 Aug 30  07:27 WARPEACE.TXT
    -rwxrwxrwx 1 502     500         1895 Apr 15  15:09 SEE-V4.FTH
    -rwxrwxrwx 1 502     500         7229 Apr 26  23:24 LIFE.FTH
    -rwxrwxrwx 1 502     500        18944 Mar  9  12:30 SPLAT-V4.FTH
    -rwxrwxrwx 1 502     500      1048576 Jan  1  00:02 TEMP.TXT
    -rwxrwxrwx 1 502     500     16777216 Jan  1  00:07 NETLOG.TXT
    
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Brisbane, Australia
  • Hi @Peter - couldn't resist and tried v4r4
    - DOFOR is looking good
    - IoT5500 builds successful up to EASYFILE, EASYNET is not yet ready.
    - separating the new version into a new folder is fine - thank you - maybe others with more Forth code will appreciate too
    - EASYFILE: I tried to use a Transcend 16 GB micro SDHC without success. Should it work or is is there still a SANDISK dependency? It could be that mine is "mis-formatted" because of many trial end errors. I ask to be sure whether I should try to reformat it which can eat up spare tachyon time :-(
    - COMPACT4r4.FTH should be renamed to COMPACT-v4r4.FTH :-)

    Again thank you for sharing and holding up the Tachyon flag so high!

    Best regards,
    proplem
    I Am One With the Forth and the Forth Is With Me
  • proplem wrote: »
    Hi @Peter - couldn't resist and tried v4r4
    - DOFOR is looking good
    - IoT5500 builds successful up to EASYFILE, EASYNET is not yet ready.
    - separating the new version into a new folder is fine - thank you - maybe others with more Forth code will appreciate too
    - EASYFILE: I tried to use a Transcend 16 GB micro SDHC without success. Should it work or is is there still a SANDISK dependency? It could be that mine is "mis-formatted" because of many trial end errors. I ask to be sure whether I should try to reformat it which can eat up spare tachyon time :-(
    - COMPACT4r4.FTH should be renamed to COMPACT-v4r4.FTH :-)

    Again thank you for sharing and holding up the Tachyon flag so high!

    Best regards,
    proplem

    I'll get down to the bottom of why some cards don't work but it should be a very minor thing I'm sure, I have cards other than Sandisk that work. I'm doing quite a bit of work on EASYFILE in 4.4 at present,

    I haven't quite gotten onto EASYNET yet but it should be straightforward enough.

    Now that the files are in their own folders I can probably remove the version from the name and leave that information in the file itself.

    V4.4 starts up in non-case sensitive mode although fast block mode load via TACHYON END is still always case sensitive. Use OFF ANYCASE to enforce case sensitivity.

    I've been using 4.3 for my projects but with these improvements and stability testing I see I can easily start using 4.4. With an SD card in I can also fast load FL to a temporary or specified file which buffers everything into the file and then loads it automatically. If you want to update a text file on the card over the console you can SAVETEXT <myfile>, paste/send the text file as you would normally and use esc to finalize. This will also update the file size in the directory. Using FL or SAVETEXT without a filename will cause it to use TEMP.TXT.

    Since the minimum cluster size is 32k bytes it doesn't matter if the file only had 4kB but the new text has 6kB etc. I like to preallocate at least 64kB though and there is no reason why you couldn't preallocate 1MB per file anyway, unless you have 8,000 of them. The cluster chain for a file is contiguous and the number of clusters allocated has to be scanned to determine the maximum but it is just as easy to preallocate anyway.

    Here is a scan of clusters of sectors with sector address header where each * represents a cluster with data (non-zero) plus I've inserted labels for id.
    Each line represents 4MB so it is interesting to see all that unused space after the MBR (really just partition info) and before the FAT tables, that's around 4MB you can hide files and config in.
    PART
    0000.0000 *...............................................................................................................................
    BOOT       FAT1
    0000.2000 **..............................................................................................................................
                                                                                                                          FAT2
    0000.4000 ............................................................................................................**..................
    0000.6000 ................................................................................................................................
    												   ROOT
    0000.8000 .........................................................................................***************************************
    0000.A000 ********************************************************************************************************************************
    0000.C000 ********************************************************************************************************************************
    0000.E000 ********************************************************************************************************************************
    0001.0000 ****************************************************************************************************************************...*
    0001.2000 ................................................................................................................................
    
    0001.8000 .................................
    ( 0014 $441E  ok )   @ROOT .LONG
    0000.9646
    ( 0015 $441E  ok )   @BOOT .LONG
    0000.2000
    ( 0013 $441E  ok )   DIR
    SCR1.5
    COMPACT .FTH .....a 0000.964E    May 21  2017 15:23   3,156
    LIFE    .FTH .....a 0000.9656    May 22  2017 04:29   7,609
    PTZ485  .FTH .....a 0000.9666    May 21  2017 01:00   875
    SEE     .FTH .....a 0000.966E    May 19  2017 13:34   1,998
    WARPEACE.TXT .....a 0000.9676    Aug 30  2015 07:27   3,226,652
    SPLAT-V4.FTH .....a 0000.AF16    Mar  9  2017 12:30   18,944
    LOVE    .WAV .....a 0000.AF3E    Feb 16  2015 08:06   14,630,692
    POPCORN .WAV .....a 0001.1EDE    Jun 17  2014 06:15   117,804
    FRED    .TXT .....a 0001.1FC6    Oct 13  2005 22:43   2,474
    ( 0014 $441E  ok )
    


    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Brisbane, Australia
  • @D.P - Ahh, you saw that stub. Yes, I may get around to it tonight and put the scanning SDRD back in and all should be good again for 4.3.

    [/quote]

    Well if you are using 4.3 for production are you logging data? If so how since APPEND is still a stub.

    I keep looking for the stub to be implemented.
  • I did quite a lot of testing of various SD Cards. I found some quirks that were not completely explained from the flowchart of commands. With that code I didn't find any that I couldn't read/write to. Some of the cards I tried were cheapie eBay 8GB and 32GB cards.

    I won't be back in Oz for 3 weeks. When I get back I will look up my notes as I don't think I have all the info on my laptop I have with me. IIRC I posted the info on a P2 thread, so I'll also look for that.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • D.P wrote: »
    @D.P - Ahh, you saw that stub. Yes, I may get around to it tonight and put the scanning SDRD back in and all should be good again for 4.3.

    Well if you are using 4.3 for production are you logging data? If so how since APPEND is still a stub.

    I keep looking for the stub to be implemented.
    [/quote]

    I'm actually working on the 4.4 version, I started checking it the other day, so with all my file system work at present I will be able to sort it out. I didn't actually use APPEND for some of these files. It's easier sometimes to create a new file each time it starts up if the old file has already been used but I might make it a point right at the moment to get APPEND working ASAP as I had already started doing so in V4.3.
    Tachyon Forth - compact, fast, forthwright and interactive
    useforthlogo-s.png
    Brisbane, Australia
Sign In or Register to comment.