I don't think we are intended to set the words with an underscore, in general. I remember something about those being used internally by the kernel, it might get confused if you manually set it.
The escape codes send color/formatting requests to the PC serial terminal program, and the PC does the work.
No noticeable impact to to performance. Very small code size. Handy in debugging if you like when Status=Good displays in green and Status=ERROR displays in RED.
Control text display color, foreground and background, 8 colors
Control cursor position on screen (up to 99 character wide, if somebody has need I can increase it to 999, but I'm saving 6 bytes)
Control underscore, reverse, bold, normal
Support cls (clearscreen), home, clear to end of screen, clear to end of line
Requires a serial terminal program that supports ANSI escape codes (TeraTerm works great)
Does not support italics, faint, cross-out, blink, or alternate fonts (unless you show me how they work, I never use them)
If anybody knows how to get the ANSI BLINK stuff to work with a serial term, please let me know. I really want the DANGER messages to flash in red.
I found out very little mistake on PropForth.spin.
\ lockclr (n1 -- n2) set lock n1...........the lock was set ... --> clear lock n1 .... the lock was clear ...
: checkdict here W@ + dictend W@ >=
if cr here W@ . dictend . _eoom clearkeys reset then ; --> if cr here W@ . dictend W@ . _eoom clearkeys reset then ;
I do experiments to see PropForthDictionaryStructure of PropForth Wiki.
fl
: dictEntryDump
dup .word 3a emit space
dup .strname cr
nfa>pfa
\ do i dup .word 3a emit space W@ dup .word space _forthpfa>nfa dup .word space .strname cr 2 +loop
do i dup .word 3a emit space W@ dup dup .word d72 >= if
space _forthpfa>nfa dup .word space .strname
else
drop
then
cr 2
+loop
cr
;
: dictDump
here W@ wlastnfa W@
begin 2dup dictEntryDump nip nfa>lfa dup W@ dup 0= until
2drop
;
I do experiments to see PropForthDictionaryStructure of PropForth Wiki.
: dictEntryDump
There is not forth-word'begin' inside dictDump. Where is wrong?
I haven't been running your examples, so I'm a little off in my understanding
Have run the dictionary dump ' words ' ?
words
This does contain
begin
, and lists ' begin' as a Forth word, and an Immediate word. Immediate words cannot be executed from the command line, only executed during compilation of a colon definition.
I attached dictionary_log.txt.
word"emit" include "begin".
But dictDump doesn't display word"begin" is included in another word.
dictDump display word"begin".
I have read PropForthStatus on Wiki.
I think PropForth3.6 is very interesting.
I don't understyand what is it below:
8 channel? ROM-less slaves?
3.6's release is next week?
I received the beta, I am testing it (trying to figure out what Sal did) so I can write the instructions; to prove to myself that I know what is going on.
The idea is to connect many props using fast serial channels to do parallel programs, so there can be more processor - cogs and more shared resources (like your SD function, or the Hive's 1 meg external RAM)
Unfortunately, I am too busy with my day job. The serial communication is the first thing on the list, SD is next; ethernet and external ram are also waiting for attention.
Cog6 ok
0 _words
NFA(Forth/Asm Immediate eXecute)Name
3D4F F wlastnfa 3D1E F lasm 3CD8 F rs? 3CA2 F pfa?
: :
: :
0D9A F _forthinitialized 0D8C F memend 0D7E F dictend 0D72 F here
Cog6 ok
c" par" _words
NFA(Forth/Asm Immediate eXecute)Name
2486 F parsenw 2466 F parsebl 243C F parseword 23A4 F parse
1702 F parat
Cog6 ok
But result of words ia same as "0 _words".
: words parsenw _words ;
Although I read comments of words, I can't understand its meaning.
How to use "words"?
_words
c" par" _words
But result of words ia same as "0 _words".
Although I read comments of words, I can't understand its meaning.
How to use "words"?
words does a dump of the forth dictionary. This correctly prints the whole dictionary, and prints flag to show if the word is F (forth) , I (immediate), or X (executes and consumes the next string in the input stream. Using the name X is a little weird but I couldn't suggest anything better.
When use with a parameter, words will print all the dictionary entries starting with the letter given in theinput stream for example
words b
will display all the words starting with b, including begin bl base between
The word "underscore words"
_words
is used internally by words and we should not use it, unless we know how to compile words into the input buffer or we will make weird things happen. You figured this out, congratulations!
Previously, you were using dict_dump and had problems. This is because you wanted to use "words" instead, I think.
You figured out the hard part, which is how to use _words, but missed the easy part, which is words displays the whole dictionary, or filters on one letter, give AFTER words in the input stream.
I'm making word's manual.
I read Control Structures word(if,do begin ..).
They have number. For example if->1235,else->1239,dothen->1235/1239 etc.
What is these number?
How are they determined?
I'm making word's manual.
I read Control Structures word(if,do begin ..).
They have number. For example if->1235,else->1239,dothen->1235/1239 etc.
What is these number?
How are they determined?
: dothen l>w dup 1235 = swap 1239 = or if dup here W@ swap - swap W! else _mmcs then ;
: then dothen ; immediate
: thens begin dup FFFF and dup 1235 = swap 1239 = or if dothen 0 else -1 then until ; immediate
: if $C_a_0branch w, here W@ 1235 w>l 0 w, ; immediate
: else $C_a_branch w, 0 w, dothen here W@ 2- 1239 w>l ; immediate
: until l>w 1317 = if $C_a_0branch w, here W@ - w, else _mmcs then ; immediate
: begin here W@ 1317 w>l ; immediate
: doloop swap l>w 2329 = if swap w, here W@ - w, else _mmcs then ;
: loop $C_a_(loop) doloop ; immediate
: +loop $C_a_(+loop) doloop ; immediate
: do $C_a_2>r w, here W@ 2329 w>l ; immediate
Ok, you ask hard questions. Already you know more about propforth than I do.
I don't know. This stuff is crazy complicated.
My GUESS is that these are the hex values of the assembler instructions that must be tested to do these branches.
For example, dothens is as support word for THENS which resolves (n) multiple THEN statements. So it has to determine which type of branch or if its the last one. So, if this is true, these are the opcodes for the branch instructions from the propeller manual.
Please let me know if this is correct or not, I could update the documentation
Otherwise I will ask Sal on the next call. What is it you are trying to do?
If I define up as
: up 0 do 1 + dup . loop ;
if I say "20 up", it counts to 20
If i say "20 up" again, it counds 21 to 40
the stack is empty when I check with st?
Why is this happening, and where is the count stored?
Most architectures (used to) support one kind of memory access by default.
For example, most 8 bit micro controllers were byte access.
So fetch and store
@
!
were obviously byte access.
Prop is different in that COG memory is mostly longs, and HUB memory tends to be most efficient when used as words, but also support byte and long access. So which to make the default?
Originally, Sal had @ and ! default to WORD in HUB memory, and Long in COG memory. We decided that in the case of the prop this was not making things clearer. so we did this:
COG access is always LONG and uses COG@ and COG!
HUB memory can be byte, word or long and is defined as
C@ C!
W@ W!
L@ L!
Nearly ALL of propforth kernel words are lower case EXCEPT for these words.
As you can guess, we tried using lowercase for these as well but the lowercase 'L' was a major irritation.
There is no @ or ! defined by default, the user can define these as a reference to one of the others or something else according to their needs.
: up 0 do 1 + dup . loop ;
if I say "20 up", it counts to 20
If i say "20 up" again, it counds 21 to 40
the stack is empty when I check with st?
Why is this happening, and where is the count stored?
This is an important question.
First, try this:
: up2 0 do i . loop ;
The loop counter variable 'i' is an artifact from the days when people only had three character to use for variable names, and it was acceptable to use stupid names in programs. Everybody is just supposed to know the I and J are the loop iteration counter variables. SOME folks get MIGHTY UPSET if we try to change these to "iteration-count" or something informative, probably because their fingers would fall off if they had to type the extra characters, and they don't know how to do a string replace. But Sal likes to go with the flow, so we left it as i.
In your example, there is nothing that you put on the stack to add 1 to.
There IS something on the stack, and that is stuff that the loop structure uses internally. AND you can mess with it, as you can see, but you shouldn't unless you know EXACTLY what you are doing, or you will bring trouble to yourself. You WILL know what this is all about in a short time, but for now, know that a loop is a boundary that can only be crossed at the beginning and at the end. Later you will see how to get around this rule and use it to your advantage, but not just yet.
tested a 2 Gig Transend micro SD card, giving me problems.
My SDHC adapter identified this as SDHC, but could not format it.
My SDSC adapter was able to format it as FAT.
Using your code, sd_init works, the menu displays reasonable values
until MBR, which says it is formatted to DOS5.0
Bios boot block is all 0000's
FAT is all 0000's
Root is all .u.u (AA55's)
U - file detail gives 384 entries of -u
entry 385 is the text of the first file in the first subdirectory
Also tested SDHC 4 gig card; h, j, k , l gives expected results
m - gives master boot record similar to successful sdsc card
b - all 0000's
f - FAT is all 0000's
r - all 0000's
u - no file (and windows does display files)
t - all 0000's
W+! was used in creating propforth, but no need arose for character or long. If you need these, they can be added to the kernel, but they turn out to be no used very often.
I added comments to sources.
And I made PDF.
I think you feel a little strange because my english is japanease-english.
sd-viewer can initialize your SD-CARD?
message is SDSC seccess?
I think sd_init don't works finely on your 2G/4G.
or collect_info may collect information finely.
Both can't display csd/cid?
Did you format SD-CARDS by Windows?
Formatted by Windows, I think its SD-CARD don't work finely on sd_viewer.
I think WORD"dup" has temprally data in somewhere.
Or "dup" may change stack top.
We may merely watch no data on stack.
This is the case where the TOP element is buffered, and does NOT register as an underflow (or overflow).
This is a design decision, as it would too much (slow things down) to test this case all the time, and most computations involve another stack element eventually anyway.
Just need to be aware that single element operations do not detect under/overflow.
I'm going to try asembler WORD. ( It merely put out pulse to P0)
But it don't work at all.
test.f
fl
0 wconstant _data
1 _data lshift constant _datam
152 asmlabel a_pulse
lockdict variable def_014F 0159 l, 014F l,
00000001 l,
E4FE1B50 l,
5C7C0000 l,
68BFED4F l,
A27E1D00 l,
7CBFE94F l,
5CFEA350 l,
78BFE94F l,
5CFEA350 l,
E4FE1D54 l,
freedict
def_014F lasm
: test 100 0 do a_pulse loop ;
{
fl
:asm
__1datam
_datam
__Edelay mov _treg5 , # 10
__C
djnz _treg5 , # __C
__Ddelayret
ret
a_pulse
\ set __1datam to output
or dira , __1datam
\ set loop-counter to 100
mov _treg6 , # 100 nr wz
__F
\ set __1datam to high
muxnz outa , __1datam
jmpret __Ddelayret , # __Edelay
\ set __1datam to low
muxz outa , __1datam
jmpret __Ddelayret , # __Edelay
djnz _treg6 , # __F
;asm
}
I did how to:
1 Loading below:
0 wconstant _data
1 _data lshift constant _datam
2 Loading asm.f
3 Loading codes from :asm to ;asm for test.f.
4 Paste outputs-code that asm.f print out to test.f
Comments
I don't think we are intended to set the words with an underscore, in general. I remember something about those being used internally by the kernel, it might get confused if you manually set it.
http://code.google.com/p/propforth/downloads/detail?name=ANSI%20Escape%20Sequences.f&can=2&q=
The escape codes send color/formatting requests to the PC serial terminal program, and the PC does the work.
No noticeable impact to to performance. Very small code size. Handy in debugging if you like when Status=Good displays in green and Status=ERROR displays in RED.
Control text display color, foreground and background, 8 colors
Control cursor position on screen (up to 99 character wide, if somebody has need I can increase it to 999, but I'm saving 6 bytes)
Control underscore, reverse, bold, normal
Support cls (clearscreen), home, clear to end of screen, clear to end of line
Requires a serial terminal program that supports ANSI escape codes (TeraTerm works great)
Does not support italics, faint, cross-out, blink, or alternate fonts (unless you show me how they work, I never use them)
If anybody knows how to get the ANSI BLINK stuff to work with a serial term, please let me know. I really want the DANGER messages to flash in red.
Thanks caskaz
Issue 16 has been opened
http://code.google.com/p/propforth/issues/detail?id=16
I'll have Sal look at it tomorrow. I have the new ALPHA release, the updates might be in as soon as tomorrow.
I do experiments to see PropForthDictionaryStructure of PropForth Wiki.
result about word'dictDump' below:
There is not forth-word'begin' inside dictDump.
Where is wrong?
I haven't been running your examples, so I'm a little off in my understanding
Have run the dictionary dump ' words ' ?
This does contain , and lists ' begin' as a Forth word, and an Immediate word. Immediate words cannot be executed from the command line, only executed during compilation of a colon definition.
Is this the issue?
I finally checked
_fcog is set internally by propforth to hold the last running forth cog.
It is only manually set by the user when you something running in for example cog 3 and you want to lock it off from propforth. In this case, to no long consider cog 3 as next available cog; and also lock off cog2 cog1 cog0, leaving only 5 and 6 for forth. (and 7 for the serial driver).
So I think what you did in the example is not correct, I think you should not use at all in this example.
I sent you a PM, please check your inbox
I attached dictionary_log.txt.
word"emit" include "begin".
But dictDump doesn't display word"begin" is included in another word.
dictDump display word"begin". I think "dict_Dump" should display whole dictionary.
But not displaying word"begin".
I think "dict_Dump" has bugs.
I'm reading spinmaker.f.
I have question.
lfa is "`word @***NFA + $10".
What does $10 mean?
I have read PropForthStatus on Wiki.
I think PropForth3.6 is very interesting.
I don't understyand what is it below:
8 channel? ROM-less slaves?
3.6's release is next week?
I received the beta, I am testing it (trying to figure out what Sal did) so I can write the instructions; to prove to myself that I know what is going on.
The idea is to connect many props using fast serial channels to do parallel programs, so there can be more processor - cogs and more shared resources (like your SD function, or the Hive's 1 meg external RAM)
Unfortunately, I am too busy with my day job. The serial communication is the first thing on the list, SD is next; ethernet and external ram are also waiting for attention.
I have question about words on forth dictionary.
Using _words below;
But result of words ia same as "0 _words".
Although I read comments of words, I can't understand its meaning.
How to use "words"?
words does a dump of the forth dictionary. This correctly prints the whole dictionary, and prints flag to show if the word is F (forth) , I (immediate), or X (executes and consumes the next string in the input stream. Using the name X is a little weird but I couldn't suggest anything better.
When use with a parameter, words will print all the dictionary entries starting with the letter given in theinput stream for example
will display all the words starting with b, including begin bl base between
The word "underscore words" is used internally by words and we should not use it, unless we know how to compile words into the input buffer or we will make weird things happen. You figured this out, congratulations!
Previously, you were using dict_dump and had problems. This is because you wanted to use "words" instead, I think.
You figured out the hard part, which is how to use _words, but missed the easy part, which is words displays the whole dictionary, or filters on one letter, give AFTER words in the input stream.
Very good!
I'm making word's manual.
I read Control Structures word(if,do begin ..).
They have number. For example if->1235,else->1239,dothen->1235/1239 etc.
What is these number?
How are they determined?
Sorry, where are you seeing this number?
There are from line No 955 in PropForthPart1.f.
Ok, you ask hard questions. Already you know more about propforth than I do.
I don't know. This stuff is crazy complicated.
My GUESS is that these are the hex values of the assembler instructions that must be tested to do these branches.
For example, dothens is as support word for THENS which resolves (n) multiple THEN statements. So it has to determine which type of branch or if its the last one. So, if this is true, these are the opcodes for the branch instructions from the propeller manual.
Please let me know if this is correct or not, I could update the documentation
Otherwise I will ask Sal on the next call. What is it you are trying to do?
how about +! ?
Thanks, Doug
: up 0 do 1 + dup . loop ;
if I say "20 up", it counts to 20
If i say "20 up" again, it counds 21 to 40
the stack is empty when I check with st?
Why is this happening, and where is the count stored?
Sorry for the noob questions.
Doug
I made sd_viewer_2.1.
Most architectures (used to) support one kind of memory access by default.
For example, most 8 bit micro controllers were byte access.
So fetch and store were obviously byte access.
Prop is different in that COG memory is mostly longs, and HUB memory tends to be most efficient when used as words, but also support byte and long access. So which to make the default?
Originally, Sal had @ and ! default to WORD in HUB memory, and Long in COG memory. We decided that in the case of the prop this was not making things clearer. so we did this:
COG access is always LONG and uses COG@ and COG!
HUB memory can be byte, word or long and is defined as
C@ C!
W@ W!
L@ L!
Nearly ALL of propforth kernel words are lower case EXCEPT for these words.
As you can guess, we tried using lowercase for these as well but the lowercase 'L' was a major irritation.
There is no @ or ! defined by default, the user can define these as a reference to one of the others or something else according to their needs.
This is an important question.
First, try this:
: up2 0 do i . loop ;
The loop counter variable 'i' is an artifact from the days when people only had three character to use for variable names, and it was acceptable to use stupid names in programs. Everybody is just supposed to know the I and J are the loop iteration counter variables. SOME folks get MIGHTY UPSET if we try to change these to "iteration-count" or something informative, probably because their fingers would fall off if they had to type the extra characters, and they don't know how to do a string replace. But Sal likes to go with the flow, so we left it as i.
In your example, there is nothing that you put on the stack to add 1 to.
There IS something on the stack, and that is stuff that the loop structure uses internally. AND you can mess with it, as you can see, but you shouldn't unless you know EXACTLY what you are doing, or you will bring trouble to yourself. You WILL know what this is all about in a short time, but for now, know that a loop is a boundary that can only be crossed at the beginning and at the end. Later you will see how to get around this rule and use it to your advantage, but not just yet.
Ok, so now try:
: up2 1 do i dup . +loop ;
: up3 1 do i 1 + dup +loop ;
Got it!
Today is SD day for me, finally
I tried everything on the menu with SDSC 1Gig.
Everything works as expected.
I could not find any errors, did you already fix the issue you had ?
I will try SDHC in a bit.
My only comment is that there are no stack or usage comments.
For example, before the definition for SD_INIT there should be a comment line that says
/ sd_init - this word must be called first to initialize all sd functions.
for collect_info is should say something like
/ collect_info - requires sd_init to have been executed. Needed for MBR, RTE
If you want I can got through and put in these type of comments and you can check them?
Other than that, this stuff is perfect.
Great work!
tested a 2 Gig Transend micro SD card, giving me problems.
My SDHC adapter identified this as SDHC, but could not format it.
My SDSC adapter was able to format it as FAT.
Using your code, sd_init works, the menu displays reasonable values
until MBR, which says it is formatted to DOS5.0
Bios boot block is all 0000's
FAT is all 0000's
Root is all .u.u (AA55's)
U - file detail gives 384 entries of -u
entry 385 is the text of the first file in the first subdirectory
T -
Clusters 00 - 29 - AA55 .u
clusters 2a - 38 - A5A5 ..
clusters 39 - Onward: 0000 ....
Also tested SDHC 4 gig card; h, j, k , l gives expected results
m - gives master boot record similar to successful sdsc card
b - all 0000's
f - FAT is all 0000's
r - all 0000's
u - no file (and windows does display files)
t - all 0000's
There is a W+!
There is no +!, as there is no clear default
W+! was used in creating propforth, but no need arose for character or long. If you need these, they can be added to the kernel, but they turn out to be no used very often.
Same goes for the coma operator.
I added comments to sources.
And I made PDF.
I think you feel a little strange because my english is japanease-english.
sd-viewer can initialize your SD-CARD?
message is SDSC seccess?
I think sd_init don't works finely on your 2G/4G.
or collect_info may collect information finely.
Both can't display csd/cid?
Did you format SD-CARDS by Windows?
Formatted by Windows, I think its SD-CARD don't work finely on sd_viewer.
Pleaase send your log.
I did experiment.
Cog6 ok
1 + dup . st?
1 ST:
Cog6 ok
1 + dup . st?
2 ST:
Cog6 ok
1 + dup . st?
3 ST:
There is no data to add on data stack.
I think WORD"dup" has temprally data in somewhere.
Or "dup" may change stack top.
We may merely watch no data on stack.
This is the case where the TOP element is buffered, and does NOT register as an underflow (or overflow).
This is a design decision, as it would too much (slow things down) to test this case all the time, and most computations involve another stack element eventually anyway.
Just need to be aware that single element operations do not detect under/overflow.
I'm going to try asembler WORD. ( It merely put out pulse to P0)
But it don't work at all.
test.f
I did how to:
1 Loading below:
0 wconstant _data
1 _data lshift constant _datam
2 Loading asm.f
3 Loading codes from :asm to ;asm for test.f.
4 Paste outputs-code that asm.f print out to test.f
Where is wrong?