I want to have a Forth word that stores a set of data to an array that other words can then access.
For example something like this:
freq_sweet_points [ number number number number
number number ]
So that would be word "freq_sweep_points" would read input expecting a "[" to start the array data and followed by
a stream of number, which may cross new line-boundary and finally stop collecting number when "]" is read in.
I want to have a Forth word that stores a set of data to an array that other words can then access.
For example something like this:
freq_sweet_points [ number number number number
number number ]
So that would be word "freq_sweep_points" would read input expecting a "[" to start the array data and followed by
a stream of number, which may cross new line-boundary and finally stop collecting number when "]" is read in.
How would that be done in Tachyon Forth?
Thanks
rich
I could give you a couple of pointers, first off to read in a number from the input stream you could just use:
GETWORD NUMBER
which will return with the number of digits and the value ( -- val digits )
Here's a live test implementation of the [ word:
[FONT=courier new]: [ BEGIN GETWORD NUMBER 0= UNTIL ; ok
IMMEDIATE ok
ok
[ 1234 5678 9000 ] ok
.S
STACK: FFFF.F9FF 0000.1234 0000.5678 0000.9000 ok
[/FONT]
So your freq_sweet_points would really just leave an address of an array which [ can be modified to store the data in after which any non-number or ] can terminate it.
More correctly then the [ word will look like this (assuming it's a long array):
[FONT=courier new]: [ ( arrary -- )
BEGIN GETWORD NUMBER WHILE OVER ! 4 + REPEAT DROP
;
IMMEDIATE
[/FONT]
So is there an 'array' data type or word?
An how would it be used?
Thanks for feedback.
rich
I assume you will be treating an area of memory as an array so you only need to supply the starting address. In typical Forth's you can always ALLOT extra bytes to any variable but if you use TABLE it will not allocate any storage so you just use that in conjunction with ALLOT like this:
TABLE freq_sweet_points #32 4 * ALLOT \ allocate a table/array of 32 longs
A number preprocessor is built into Tachyon that does a quick check to see if it looks like a number and whether or not it has a suitable prefix or a suffix. Doing this first speeds up processing of numbers which would otherwise have do undergo a full dictionary search first. Besides the standard "d" and "h" suffix for decimal and hex notation TF also allows prefix notation such as $ and % for hex and binary but for decimal I chose to adopt the traditional # symbol that we use do denote a number (which is always decimal). So these prefix and suffix modes override whatever base Forth has been set to. For instance, if we have set Forth to HEX we do not need to figure out how to express decimal 5000 in hex nor do we have to use DECIMAL, instead we can just type #5000 or 5000d or even #5,000 as alphas and symbols are allowed to be embedded in numbers. This means we can express port pin 27 as #P27 if that helps us to recognize that as P27.
Using prefixed or suffixed numbers improves readability and also prevents errors if the base has been set to something different too.
\ is a comment to the end of the line (and not echoed). The two individual ticks together as used in Spin can also be used (not a single tick which is a reserved Forth word)
( is a comment to a matching )
{ is normally a multi-line comment (not echoed) to another matching } where nesting is counted.
EDIT: BTW, you can also enter ASCII and control characters using the prefix method. "?" will leave a $3F on the stack while a ^A will leave a 1 (control A).
I am trying to figure out the v2.3 source code i fetched out of your drop box and i wonder about the PUB Start rountine.
That is:
<code>
repeat 6
cognew(@RESET, @IDLE)
</code>
Now as understand it RESET is the cog ID so why would want to repeat the same instruction six times with the same cog ID?
I am trying to figure out the v2.3 source code i fetched out of your drop box and i wonder about the PUB Start rountine.
That is:
<code>
repeat 6
cognew(@RESET, @IDLE)
</code>
Now as understand it RESET is the cog ID so why would want to repeat the same instruction six times with the same cog ID?
Please forgive the ignorance.
Regards,
rich
RESET is the address of the kernel cog image and IDLE is the parameter that's passed to it which then gets loaded into the Forth instruction Pointer "IP". COGNEW will do this six times so that 6 cogs will end up with the Forth kernel loaded but running an IDLE loop which waits for something to run. Finally the Spin cog that execute this gets replaced with a serial cog which then reuses the now "not needed" kernel cog image in HUB RAM as a receive buffer.
First of all: Thank you for all the work! I've heard D.P fighting the Forth battle in the C world, and thought I'd give it a try.
I uploaded 140121-2100 last night and spotted a small missing update. Near the end, .INFO calls I2CBUS on line 7. Should be .I2CBUS
Thanks, I thought I checked it all but I think I was being distracted at the time and forgot. I wanted to standardize all the diagnostic words which print to the console so I decided to make them all dot type words and be done with it. I will check and update the files.
IMO I find it a big waste of time comparing languages as Forth is not just a language, it's the whole target O/S and development environment. Furthermore I can't help but compare effectiveness and efficiency of different ways of arriving at solutions. So I quietly chuckle to myself when I can see how simple a solution could be yet observe how people in general marvel at complexity.
I am afraid that I must add to the bad news .. The Dropbox code I took at 1500 EST today, Saturday ...
I built this far ... MOUNT works but notice the MODULES word fails even though the boot code got it to work.
* Propeller .:.:--TACHYON--:.:. Forth V23140122.0000
NAMES: *$5360...74DB for 8571 (1037 bytes added)
CODE: * $0000...49C1 for 10310 (1748 bytes added)
CALLS: *0199 vectors free
RAM: * *2463 bytes free
AUTORUN EXTEND.boot
MODULES LOADED:*
42ED: W5200.fth * * * * * WIZNET W5200 driver 131211.1530*
39A0: MULTIFILE.fth * * * FAT32/16 MultiFile Layer V1.1 140123-0000*
324F: SDCARD.fth * * * * *SD CARD Toolkit - 140121.2200*
30A4: QuickStart.fth * * *QuickStart + W5200 HARDWARE DEFINITIONS 131204.1200*
1800: EXTEND.fth * * * * *Primary extensions to TACHYON kernel - 140121-2100*
--------------------------------------------------
ok
MOUNT Mounted SD Card
Media mounted as 3C18.8F1F NO NAME FAT32 Cluster size = 32,768 Sectors = 15,269,888 ok
ok
ok
MODULES ??? ok
ok
Then when I went to finish up ... when I loaded NETWORK.FTH it burped at the same place every time and I cannot figure what;s wrong
0256 ok
0257 ok
pub GETCMD
0258
GET$ FORTH$ $!
0259
FORTH$ 2 LEFT$ " /:" COMPARE$ \
IF
0260
GET$ DUP LEN$ 2- RIGHT$ FORTH$ $! \
THEN
0261
;
0262 ok
0263 ok
pub GETPAGE
0264
GET$ " /" COMPARE$ \
IF " HOME.HTM" DUP GET$ ???
Sorry guys, I'm a bit busy at the moment with social engagements and I thought I had updated the dropbox versions but the code does work from the latest Google docs. I will have a spare moment in another couple of hours and have a look then.
The dropbox version is the same except for one error in that I2CBUS has been renamed .I2CBUS to conform to the diagnostic word naming. So I've fixed that and MODULES is of course now .MODULES.
[FONT=courier new]00:00:00 End of source code, 1558 lines processed and 0000 errors found
Load time = 30,174ms
NAMES: $5ED6...74DB for 5637 (3138 bytes added)
CODE: $0000...30A4 for 6815 (6308 bytes added)
CALLS: 0511 vectors free
RAM: 11826 bytes free
ok
\
EEPROM ... 9600d SERBAUD ok
runtime ~ ok
{ ok
ok
ok
?BACKUP ok
ok
[/FONT]
The dropbox version is the same except for one error in that I2CBUS has been renamed .I2CBUS to conform to the diagnostic word naming. So I've fixed that and MODULES is of course now .MODULES.
[FONT=courier new]00:00:00 End of source code, 1558 lines processed and 0000 errors found
Load time = 30,174ms
NAMES: $5ED6...74DB for 5637 (3138 bytes added)
CODE: $0000...30A4 for 6815 (6308 bytes added)
CALLS: 0511 vectors free
RAM: 11826 bytes free
ok
\
EEPROM ... 9600d SERBAUD ok
runtime ~ ok
{ ok
ok
ok
?BACKUP ok
ok
[/FONT]
This has not fixed the reported bug listed in post 1092. After calling SPRS all other words are "broken" ??? CLS .MODULES APIN ....
Propeller .:.:--TACHYON--:.:. Forth V23140122.0000
MODULES LOADED:
1800: EXTEND.fth Primary extensions to TACHYON kernel - 140121-2100
ok
0000
t1F0: PAR = $0000_15D4 %0
t1F1: CNT = $3856_A188 %0
t1F2: INA = $F270_007E %1
t1F3: INB = $0000_0000 %0
t1F4: OUTA = $4000_0000 %0
t1F5: OUTB = $0000_0000 %0
t1F6: DIRA = $4000_0000 %0
t1F7: DIRB = $0000_0000 %0
t1F8: CTRA = $0000_0000 %0
t1F9: CTRB = $0000_0000 %0
t1FA: FRQA = $0000_0000 %0
t1FB: FRQB = $0000_0000 %0
t1FC: PHSA = $0000_0000 %0
t1FD: PHSB = $0000_0000 %0
t1FE: VCFG = $0000_0000 %0
t ok: VSCL = $0000_0000 %0 \ This line is suspect, time for me to look at the SPRS implementation
.MODULES ??? CLS ??? #15 APIN ???
Changing SPRS this way resolves the listed problem, seems the calls to .NUM is the issue, more digging to do
pub SPRS ( -- \ Dump the cog's SPRs with labels in both HEX and BINARY )
#16 0 DO CR I $1F0 + .WORD ." : "
I 2* 2* " PAR CNT INA INB OUTAOUTBDIRADIRBCTRACTRBFRQAFRQBPHSAPHSBVCFGVSCL" + 4 TYPE
." = $" I SFR@ .
\ DUP $4810 .NUM ." %" $6002 .NUM
LOOP
;
This has not fixed the reported bug listed in post 1092. After calling SPRS all other words are "broken" ??? CLS .MODULES APIN ....
Propeller .:.:--TACHYON--:.:. Forth V23140122.0000
MODULES LOADED:
1800: EXTEND.fth Primary extensions to TACHYON kernel - 140121-2100
ok
0000
t1F0: PAR = $0000_15D4 %0
t1F1: CNT = $3856_A188 %0
t1F2: INA = $F270_007E %1
t1F3: INB = $0000_0000 %0
t1F4: OUTA = $4000_0000 %0
t1F5: OUTB = $0000_0000 %0
t1F6: DIRA = $4000_0000 %0
t1F7: DIRB = $0000_0000 %0
t1F8: CTRA = $0000_0000 %0
t1F9: CTRB = $0000_0000 %0
t1FA: FRQA = $0000_0000 %0
t1FB: FRQB = $0000_0000 %0
t1FC: PHSA = $0000_0000 %0
t1FD: PHSB = $0000_0000 %0
t1FE: VCFG = $0000_0000 %0
t ok: VSCL = $0000_0000 %0 \ This line is suspect, time for me to look at the SPRS implementation
.MODULES ??? CLS ??? #15 APIN ???
Changing SPRS this way resolves the listed problem, seems the calls to .NUM is the issue, more digging to do
pub SPRS ( -- \ Dump the cog's SPRs with labels in both HEX and BINARY )
#16 0 DO CR I $1F0 + .WORD ." : "
I 2* 2* " PAR CNT INA INB OUTAOUTBDIRADIRBCTRACTRBFRQAFRQBPHSAPHSBVCFGVSCL" + 4 TYPE
." = $" I SFR@ .
\ DUP $4810 .NUM ." %" $6002 .NUM
LOOP
;
I've checked this a bit further and while it appears to work first off it then starts playing up but comes good on a reset. I will back track to find out what happened.
If i go to the Tachyon Dropbox what is the newest version. I have been taking
"Tachyon v2.3.spin" but i notice some number named files. Are they more recent?
If i go to the Tachyon Dropbox what is the newest version. I have been taking
"Tachyon v2.3.spin" but i notice some number named files. Are they more recent?
Thanks much
rich
The plain V2.3 is always the most current with any numbered ones representing the backup files in YYMMDD format but they are all in their own folders so only the most current should be visible in the root Tachyon directory.
This has not fixed the reported bug listed in post 1092. After calling SPRS all other words are "broken" ??? CLS .MODULES APIN ....
This bug was caused by a reduction in the size of numpad down to 39 to allow other task variables (REG) to be long aligned. The long formatted binary number exceeded its buffer and zapped the write index for that buffer so the next character wrote elsewhere in memory!! I have now given that numpad 4 extra bytes which keeps the alignment and have removed allocation for defunct color and pixel pointers (from V1.0).
This bug never showed up as I haven't done an SPRS (now .SPRS) for quite some time. I am running some more tests but so far so good. So please note that many of the diagnostic words now begin with a dot.
I am still having trouble loading NETWORK.FTH. Load's clean as a whistle all the way through and including W5200.FTH then when I try to load NETWORK it hiccups at the same spot every time .
I am still having trouble loading NETWORK.FTH. Load's clean as a whistle all the way through and including W5200.FTH then when I try to load NETWORK it hiccups at the same spot every time .
There's a ton of fat in EXTEND and by the time you start loading all these modules in you are running out of memory so on a cold start before you have loaded in EXTEND just define a word called SMALL, I type CREATE SMALL then load in EXTEND, hardware headers, SD, FAT, W5200, NETWORK and end up with around 3K free which is plenty enough for the application itself.
ok
DECIMAL ok
200 5 / . 40 ok
-200 5 / . 858993419 ok
200 -5 / . 0 ok
-200 -5 / . 0 ok
ok
-100 10 / . 429496719 ok
-200 10 / . 429496709 ok
ok
There is a problem with dividing negative numbers in TACHYON???
NickL
The / is actually a U/ so I need to separate this into / and U/. I will patch the kernel now so that the / in the PASM kernel actually becomes U/ and / will be defined like this (for now):
: / OVER ABS OVER ABS U/ ROT 1 ROL ROT 1 ROL XOR 1 AND ?NEGATE ;
My bad again, I still had the slow debug versions of certain block words in NETWORK which I have just changed back to the faster version so FTP and HTTP block transfers should work a lot faster. Maybe I will look at doing a faster version still. The dropbox version has been updated.
Tackyon keeps getting more and more interesting. It is still my intention to jump over to Tachyon when the Propeller 2 arrives.
PropForth was just for getting started, Pfth has been very good to help me learn PASM by studying the eForth model of assembler Forth code and comparing it to what Pfth has done.
But I suspect that your deployment on the Propeller 2 will lead the way. I am looking forward to it.
Tackyon keeps getting more and more interesting. It is still my intention to jump over to Tachyon when the Propeller 2 arrives.
PropForth was just for getting started, Pfth has been very good to help me learn PASM by studying the eForth model of assembler Forth code and comparing it to what Pfth has done.
But I suspect that your deployment on the Propeller 2 will lead the way. I am looking forward to it.
If I had spent all my time on P2 development then it would be very interesting academically but like all other P2 software it would be practically useless for now. With all fingers crossed we would hope for more than just a few sample chips when they become available if we are to deploy even a small quantity of preproduction units based on P2 out there. Certainly the Ethernet side of things will be much better still. If I can drag myself away from real and immediate use of P1 then I may start firing up my DE2 as I want to test out some of this Ethernet stuff. Since P1 has lots of uses as it is it just makes sense to keep developing TF for it and it may be at least a year assuming everything happens as we hope before P2 really starts to make it into commercial product anyway.
If I had spent all my time on P2 development then it would be very interesting academically but like all other P2 software it would be practically useless for now. With all fingers crossed we would hope for more than just a few sample chips when they become available if we are to deploy even a small quantity of preproduction units based on P2 out there. Certainly the Ethernet side of things will be much better still. If I can drag myself away from real and immediate use of P1 then I may start firing up my DE2 as I want to test out some of this Ethernet stuff. Since P1 has lots of uses as it is it just makes sense to keep developing TF for it and it may be at least a year assuming everything happens as we hope before P2 really starts to make it into commercial product anyway.
As with dating and courting so it is with hardware/software: "Date what you see, not the potential". I truly appreciate your focus and attention to detail regarding P1 and Tachyon Peter.
Is there a ways to list the dependances of a word.
That is, start with a word and list all the other words it calls down to the root of the word.
Thanks
rich
I started a long reply and then scrubbed it as I am a little confused as to what you are asking. A decompilation will list all the words it calls although source code is open and easily accessed for this purpose. I think where I am confused is when you talk about calling down to "the root" of a word which might mean iteratively decompiling perhaps? Do you have an example or maybe just understanding what it is you are trying to achieve would help.
Comments
I want to have a Forth word that stores a set of data to an array that other words can then access.
For example something like this:
freq_sweet_points [ number number number number
number number ]
So that would be word "freq_sweep_points" would read input expecting a "[" to start the array data and followed by
a stream of number, which may cross new line-boundary and finally stop collecting number when "]" is read in.
How would that be done in Tachyon Forth?
Thanks
rich
GETWORD NUMBER
which will return with the number of digits and the value ( -- val digits )
Here's a live test implementation of the [ word: So your freq_sweet_points would really just leave an address of an array which [ can be modified to store the data in after which any non-number or ] can terminate it.
More correctly then the [ word will look like this (assuming it's a long array):
An how would it be used?
Thanks for feedback.
rich
I assume you will be treating an area of memory as an array so you only need to supply the starting address. In typical Forth's you can always ALLOT extra bytes to any variable but if you use TABLE it will not allocate any storage so you just use that in conjunction with ALLOT like this:
TABLE freq_sweet_points #32 4 * ALLOT \ allocate a table/array of 32 longs
What does the # in front of the 32 do?
Is "\" the beginning of a line comment?
Thanks much
rich
Using prefixed or suffixed numbers improves readability and also prevents errors if the base has been set to something different too.
\ is a comment to the end of the line (and not echoed). The two individual ticks together as used in Spin can also be used (not a single tick which is a reserved Forth word)
( is a comment to a matching )
{ is normally a multi-line comment (not echoed) to another matching } where nesting is counted.
EDIT: BTW, you can also enter ASCII and control characters using the prefix method. "?" will leave a $3F on the stack while a ^A will leave a 1 (control A).
I am trying to figure out the v2.3 source code i fetched out of your drop box and i wonder about the PUB Start rountine.
That is:
<code>
repeat 6
cognew(@RESET, @IDLE)
</code>
Now as understand it RESET is the cog ID so why would want to repeat the same instruction six times with the same cog ID?
Please forgive the ignorance.
Regards,
rich
I uploaded 140121-2100 last night and spotted a small missing update. Near the end, .INFO calls I2CBUS on line 7. Should be .I2CBUS
Thanks, I thought I checked it all but I think I was being distracted at the time and forgot. I wanted to standardize all the diagnostic words which print to the console so I decided to make them all dot type words and be done with it. I will check and update the files.
IMO I find it a big waste of time comparing languages as Forth is not just a language, it's the whole target O/S and development environment. Furthermore I can't help but compare effectiveness and efficiency of different ways of arriving at solutions. So I quietly chuckle to myself when I can see how simple a solution could be yet observe how people in general marvel at complexity.
I built this far ... MOUNT works but notice the MODULES word fails even though the boot code got it to work.
Then when I went to finish up ... when I loaded NETWORK.FTH it burped at the same place every time and I cannot figure what;s wrong
Sorry guys, I'm a bit busy at the moment with social engagements and I thought I had updated the dropbox versions but the code does work from the latest Google docs. I will have a spare moment in another couple of hours and have a look then.
This has not fixed the reported bug listed in post 1092. After calling SPRS all other words are "broken" ??? CLS .MODULES APIN ....
Changing SPRS this way resolves the listed problem, seems the calls to .NUM is the issue, more digging to do
I've checked this a bit further and while it appears to work first off it then starts playing up but comes good on a reset. I will back track to find out what happened.
If i go to the Tachyon Dropbox what is the newest version. I have been taking
"Tachyon v2.3.spin" but i notice some number named files. Are they more recent?
Thanks much
rich
This bug was caused by a reduction in the size of numpad down to 39 to allow other task variables (REG) to be long aligned. The long formatted binary number exceeded its buffer and zapped the write index for that buffer so the next character wrote elsewhere in memory!! I have now given that numpad 4 extra bytes which keeps the alignment and have removed allocation for defunct color and pixel pointers (from V1.0).
This bug never showed up as I haven't done an SPRS (now .SPRS) for quite some time. I am running some more tests but so far so good. So please note that many of the diagnostic words now begin with a dot.
There's a ton of fat in EXTEND and by the time you start loading all these modules in you are running out of memory so on a cold start before you have loaded in EXTEND just define a word called SMALL, I type CREATE SMALL then load in EXTEND, hardware headers, SD, FAT, W5200, NETWORK and end up with around 3K free which is plenty enough for the application itself.
There is a problem with dividing negative numbers in TACHYON???
NickL
The / is actually a U/ so I need to separate this into / and U/. I will patch the kernel now so that the / in the PASM kernel actually becomes U/ and / will be defined like this (for now):
: / OVER ABS OVER ABS U/ ROT 1 ROL ROT 1 ROL XOR 1 AND ?NEGATE ;
EDIT: the dropbox files have been updated
PropForth was just for getting started, Pfth has been very good to help me learn PASM by studying the eForth model of assembler Forth code and comparing it to what Pfth has done.
But I suspect that your deployment on the Propeller 2 will lead the way. I am looking forward to it.
If I had spent all my time on P2 development then it would be very interesting academically but like all other P2 software it would be practically useless for now. With all fingers crossed we would hope for more than just a few sample chips when they become available if we are to deploy even a small quantity of preproduction units based on P2 out there. Certainly the Ethernet side of things will be much better still. If I can drag myself away from real and immediate use of P1 then I may start firing up my DE2 as I want to test out some of this Ethernet stuff. Since P1 has lots of uses as it is it just makes sense to keep developing TF for it and it may be at least a year assuming everything happens as we hope before P2 really starts to make it into commercial product anyway.
Is there a ways to list the dependances of a word.
That is, start with a word and list all the other words it calls down to the root of the word.
Thanks
rich
As with dating and courting so it is with hardware/software: "Date what you see, not the potential". I truly appreciate your focus and attention to detail regarding P1 and Tachyon Peter.
Is there any chance Tackyon might support serial file transfers via packets? Such as Xmodem or Kermit.
This might open up some interesting avenues for development.
I started a long reply and then scrubbed it as I am a little confused as to what you are asking. A decompilation will list all the words it calls although source code is open and easily accessed for this purpose. I think where I am confused is when you talk about calling down to "the root" of a word which might mean iteratively decompiling perhaps? Do you have an example or maybe just understanding what it is you are trying to achieve would help.